November 10th, 2013, 09:04 PM
Horizontal Scrollbar Issue - Narrow Dragging Area
Increasing the width setting of a horizontal scrollbar with a list box did not produce the desired effect,
to spread the scrollbar arrows over a wider area.
As you can see when you run the code, the dragging area is small.
Can the standard tkinter horizontal scrollbar be set up with a larger dragging area?
edited: per comments from dwblas on importing tkinter, and using Fill=X with horizontal scrollbar
###import tkinter as tk - not needed
from tkinter import *
def __init__(self, master):
self.master = master
self.frame = Frame(master, borderwidth=2, relief=GROOVE)
self.listbox = Listbox(self.frame, font=('Courier', 12, 'roman'),
self.scrollbar = Scrollbar(self.frame, orient=HORIZONTAL,
self.scrollbar.pack(side=BOTTOM, fill=X, expand=True)
for item in ['ham', 'eggs', 'spam', 'toast', 'juice']:
self.listbox.insert(END, (item + ' ') * 15)
def OnHsb(self, *args):
### master = tk.Tk()
master = Tk()
app = Test_HScrolling(master)
Last edited by pyJer; November 11th, 2013 at 12:51 PM.
Reason: apply solution from dwblas
November 11th, 2013, 11:16 AM
I could not get your code to run because you are using both tk.Tk() and import *, pick one or the other. In any case the problem seems to be that you pack the scrollbar with fill=Y (would yield a tall/large size on the Y axis) instead of fill=X (or fill='x' depending on how you import Tkinter).
Last edited by dwblas; November 11th, 2013 at 11:30 AM.
November 11th, 2013, 01:20 PM
Thanks dwblas for explaining in a way that it first became obvious to me: fill=Y and fill=X are referring to
the Y and X axis, not 'Y' for YES and 'X' for NO. (I would use a lit lightbulb icon here if they had one)
I've edited the code above with the changes you suggested, including the incorrect double importing of tkinter.