[Tutor] Tk Listbox scrollbars

andy surany mongo57a@comcast.net
Thu Jan 9 19:29:23 2003


Got it! The following worked for me (based on your example...):

tbar=Scrollbar(self)
tbar.config(command=self.makelist.xview, orient=HORIZONTAL)
tbar.pack(side=BOTTOM, fill=X)

Thanks so much!!!

Andy
-----Original Message-----
From: Isaac Hall <hall@ouhep1.nhn.ou.edu>
To: andy surany <mongo57a@comcast.net>
Cc: tutor@python.org <tutor@python.org>
Date: Tuesday, January 07, 2003 8:18 PM
Subject: Re: [Tutor] Tk Listbox scrollbars


>Hi Andy,
>
>You are in luck.  I had to write this exact thing not long ago, so I
will
>just copy for you the code that I have written to do this.  It is in
the
>form of a class, but I you can take the important things out of it.
>
>I use grid here, but pack can be used in the same way.
>I should note that when I used pack, the thing looked a little
different,
>but not by much.  The only difference here in calling this instead of a
>listbox is that the box is class.box
>
>
>
>from Tkinter import *
>class ScrolledListbox(Frame):
>    def __init__(self,parent):
> Frame.__init__(self,parent)
> self.yScroll=Scrollbar(self,orient=VERTICAL)
> self.xScroll=Scrollbar(self, orient=HORIZONTAL)
> self.box=Listbox(self,xscrollcommand=self.xScroll.set,
> yscrollcommand=self.yScroll.set,bg='white')
> self.box.grid(row=0,column=0,sticky=N+S+E+W)
> self.xScroll.grid(row=1,column=0,sticky=E+W)
> self.yScroll.grid(row=0,column=1,sticky=N+S)
> self.xScroll["command"]=self.box.xview
> self.yScroll["command"]=self.box.yview
>
>
>Ike
>
>On Tue, 7 Jan 2003, andy surany wrote:
>
>> Hello all,
>>
>> I wrote a program for a scrolled list containing a Y-axis scrollbar
>> which has been working fine. At this point, my data is also
overflowing
>> the width of the box, so I have added an X-axis scrollbar.
>>
>> Both scrollbars appear, but the x-axis scrollbar is "vertical" (and
>> tiny...and I press the up or down arrow to move left or right). What
I
>> want is a "slider" similar to the y scroll bar. I'm pretty sure that
the
>> error is in the way that I am packing the widget, as follows:
>>
>> sbar.pack(side=RIGHT, fill=Y) # This is for the Y-axis bar and it
works
>> correctly
>> tbar.pack(side=BOTTOM) # This places the X-axis bar as described
above
>>
>> TIA
>>
>> -Andy
>>
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>--
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor