tkinter puzzler

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Thu May 12 03:41:06 EDT 2005


Paul Rubin wrote:
> I have a gui with a bunch of buttons, labels, the usual stuff.  It
> uses the grid manager:
> 
>    gui = Frame()
>    gui.grid()
>    gui.Label(....).grid()  # put some widgets into the gui
>    ...    # more widgets
> 
> Now at the the very bottom of the gui, I want to add two more buttons,
> let's say "stop" and "go".  I want "stop" to appear in the gui's lower
> left corner and "go" to appear in the gui's lower right corner.
> Suppose that up to now, row 16 is the last row in the gui.  Then this
> works:
> 
>     Button(gui, text="stop").grid(sticky=W)   # starts row 17
>     Button(gui, text="go").grid(row=17, column=1, sticky=E)
> 
> But I don't really want that hardwired row number and I don't want to
> keep counting rows and adjusting stuff if I stick new rows in the gui.
> So I try the obvious, make one Frame widget containing both new buttons:
>     stopgo = Frame(gui)
>     Button(stopgo, "stop").grid(sticky=W)
>     Button(stopgo, "go").grid(sticky=E)
> 
> and try to stretch it across the bottom row of the gui:
> 
>     stopgo.grid(sticky=E+W)
> 
> However, the buttons keep coming out centered in the gui's bottom row
> pretty much no matter what I do (I've tried all sorts of combinations).
> 
> Am I missing something?  I'm not a tkinter whiz and this stuff is
> pretty confusing.  I did come up with an ugly workaround that I'll
> spare you the agony of seeing, but there should be a natural way to do
> this.
> 
> Thanks for any advice.

Sorry to say Paul but you may have to show us that ugly code!  I'm no
whiz with the grid manager (I prefer pack!) but seeing your code will
help us help you

I suspect you need to look at the columnconfigure / rowconfigure methods
of the container (toplevel or frame)


Martin
















More information about the Python-list mailing list