Tkinter: scrollbar in grid-managed frame

jepler at unpythonic.net jepler at unpythonic.net
Wed Nov 16 16:47:48 EST 2005


Tkinter "frame"s don't scroll.  Instead, you need to use something like
bwidget's "ScrollableFrame" widget.  You may want to combine this with
bwidget's "ScrolledWindow".

Below is an example which uses my "pybwidget" package, available at
	http://tkinter.unpy.net/bwidget/
# ----------------------------------------------------------------------
import Tkinter, bwidget
 
t = Tkinter.Tk()
s = bwidget.ScrolledWindow(t, auto="vertical", scrollbar="vertical")
f = bwidget.ScrollableFrame(s, constrainedwidth=True)
g = f.getframe()

for i in range(20):
    Tkinter.Label(g, text="Field %d:  " % i).grid(row=i, column=0, sticky="w")
    Tkinter.Entry(g, width=25).grid(row=i, column=1, sticky="ew") 
g.grid_columnconfigure(1, weight=1)

s.setwidget(f)
s.pack(fill="both", expand=1)
t.mainloop()
# ----------------------------------------------------------------------

Jeff

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051116/8f256037/attachment.sig>


More information about the Python-list mailing list