[Tkinter-discuss] Tkinter page layout

Ferg, Stephen - BLS Ferg.Stephen at bls.gov
Wed Nov 5 17:21:36 CET 2008

Next, if I try to pack ANYTHING inside rightframe, it shrinks down to 
size and totally distorts my screen dimensions. Here is the exact same 
code, adding a label widget in self.rightframe. It completely shrinks 
rightframe and distorts the screen dimensions. Does my question make 
sense now?

Maybe "Thinking in Tkinter" can shed some light on your situation...


Sizing windows can be a frustrating experience when working with
Tkinter. Imagine this situation. You believe in iterative development,
so first you carefully lay out a frame with the height and width
specification that you want. You test it and you see that it works. Then
you move on to the next step, and add some buttons to the frame. You
test it again, but now to your surprise Tkinter is acting as if there
were no "height" and "width" specifications for the frame, and the frame
has snapped down to tightly encase the buttons. 

What's going on ???!!! 

Well, the packer's behavior is inconsistent. Or, shall we say: the
packer's behavior depends on a lot of situational factors. The bottom
line is that the packer will honor the size request of a container if
the container is empty, but if the container contains any other widgets,
then the elastic nature of the container comes to the fore -- the
"height" and "width" settings for the container are ignored, and the
size of the container is adjusted to enclose the widgets as closely as

The bottom line is that you really cannot control the size of a
container that contains widgets. 

What you CAN control is the the initial size of the entire root window,
and you do this with the Window Manager "geometry" option. 

<more discussion follows>

and more generally...

-- Steve Ferg

Tkinter-discuss mailing list
Tkinter-discuss at python.org

More information about the Tkinter-discuss mailing list