Tkinter: Scrollable buttons
sragsdale at my-deja.com
sragsdale at my-deja.com
Tue Oct 5 21:06:13 EDT 1999
I've got a big panel full of buttons and such, and I need to add a
scroll bar so that I can move up and down the list. The following code
will construct something that _looks_ good, but the scrollbar won't
actually do anything. Any idea what's wrong?
#######################################################
#!/usr/local/bin/python
from Tkinter import *
class App(Frame):
def __init__(self,parent):
Frame.__init__(self,parent)
self.pack(expand=YES,fill=BOTH)
items = Canvas(self)
items.pack(anchor=N, expand=YES, fill=BOTH)
scroll = Scrollbar(items)
scroll.config(command=items.yview, relief=SUNKEN)
scroll.pack(side=RIGHT, fill=Y)
items.config(yscrollcommand=scroll.set, relief=SUNKEN)
for i in range(1,100):
b = Button(items,text=str(i))
b.pack()
myapp = App(None)
myapp.mainloop()
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list