filling a frame with a widget

Fredrik Lundh fredrik at pythonware.com
Wed Oct 4 08:39:26 EDT 2006


Paolo Pantaleo wrote:

>I have this code
>
> from Tkinter import *
>
> root=Tk()
> Button(root).pack(fill=BOTH)
> root.mainloop()
>
> I would expect the button filling all the client draw area of the
> Frame, but when I resize the root window the button becomes wider, but
> not higher ( I get some empty space under the button).

pack(fill=BOTH, expand=1) should do the trick.

the pack geometry manager works by slicing off vertical or horizontal areas from
the parent, one area per widget.  the "fill" option controls how to place the widget
inside that area, the "expand" option controls how to handle any extra space left
in the parent.  if "expand" isn't set for any child widget, the extra space is left un-
used.

</F> 






More information about the Python-list mailing list