Tkinter: scrollbar in grid-managed frame

anx at io.us anx at io.us
Wed Nov 16 05:11:14 CET 2005


I've got a grid-managed frame, containing a column of Labels, and a
corresponding column of Entry widgets. I'd like to be able to display
dozens, or even hundreds of rows, and use a vertical scrollbar to
scroll through them in the frame. So far i can get a scrollbar to
display, but it won't scroll anything. So that's definately wrong. And
the columns just chop off at the bottom of the frame, but resizing the
window won't make the frame show more rows. Here's a rough sketch of
what i've done:

    mw = Tk()
    mainFrame = Frame( mw, borderwidth=5, relief=GROOVE, )
    mainFrame.pack( side=TOP, anchor=N, expand=True, fill=BOTH, )

    vertSB = Scrollbar( mainFrame, orient=VERTICAL, )
    vertSB.grid( padx=1, column=0, rowspan=15, columnspan=1, sticky=NS, )
    mainFrame.columnconfigure( 0, weight=1 )

Next i iterate through a simple dict, constructing a Label (in column
1) for each key, and an Entry (in column 2) for each value.

How do i make the Scrollbar fill all of column 0, no matter how many
rows are displayed, and stretch/shrink with mainFrame's size? Do i
have to catch resizing events, calculate how many rows are now
showing, and adjust rowspan?

How do i make my grid show more rows when i expand my window?

Am i going about this entirely the wrong way? Is grid the wrong
geometry manager to use for this frame?

Thanks,
E

-- 



More information about the Python-list mailing list