First try at Tkinter stuff

Matt Gushee mgushee at havenrock.com
Fri Jan 7 08:04:05 EST 2000


Timothy Grant <tjg at avalongroup.net> writes:

> I've got a window that displays four frames. It does it quite nicely and
> they look very nice. However, when I add a label or a button, the frame
> to which I add the label or button shrinks to the size of the button.
> This is completely undesirable behaviour.

Actually, it's completely desirable in many cases ;-). The frame is  
supposed to be a generic container for whatever you want, and is often
used as the base class for compound or customized widget. So by
default it has as few of its own characteristics/behavior as
possible; e.g., it automatically scales to fit whatever's inside it.

But I can understand your frustration.

> I have tried using both .pack
> and .grid, but I guess I don't understand how they are supposed to
> work.

Or you're just missing a small piece of the puzzle.

>         SupplierFrame.grid(row=0, column=0, rowspan=2)

Try this instead:

	SupplierFrame.grid(row=0, column=0, rowspan=2, sticky=N+S+E+W)

... or in your case, 'sticky=N+S' might be enough.

If you were packing instead of gridding the SupplierFrame, you would
use the options 'fill' and possibly 'expand':

	SupplierFrame.pack(expand=YES, fill=BOTH)

... or maybe just 'fill=Y' or 'fill="y"'. Fill affects the size of the 
packed widget, while 'expand' affects the cavity it rests in -- and
that distinction probably isn't clear, but I don't know how to make it 
any clearer in words. Just try it with and without 'expand' and see
what works. BTW, you may know this, but don't try to mix pack() and
grid() within the same container widget.

You can also pass options to an already gridded/packed widget with
grid_configure() or pack_configure().

Hope this helps a bit.

-- 
Matt Gushee
Portland, Maine, USA
mgushee at havenrock.com
http://www.havenrock.com/



More information about the Python-list mailing list