[Tkinter] Geometry Managers differences

Matthew Dixon Cowles matt at mondoinfo.com
Wed May 2 19:36:29 CEST 2001


On Wed, 02 May 2001 14:24:17 GMT, Nicola S. <stain at prigioniero.it>
wrote:

>hi everyone, what are the differences between the geometry managers
>in terms of performance? 

I don't know about their relative performance since they're mostly
useful in different contexts.

>when is one manager better than the other?

The packer is the most general-purpose of them. It pushes things up
against one another. It's handy for, for example, a row of
buttons. You can say, for example: "Push this button over to the
left. Now push this other button against whatever's on the left".

Since the packer can only push things in one direction, you sometimes
need to create invisible frames to get the arrangement you want. You
might, for example, pack some buttons on the left of an invisible
frame and then pack the frame against the top of your main window and
then pack something else (perhaps a text widget) upwards against the
invisible frame.

The grid manager lays widgets out in a table, rather like formatting
a spreadsheet or an HTML table. It understands rows and columns and
widgets can span more than one row or column. It tends to be handy
for dialogs and the like.

The place manager allows you to place widgets relative to your window
or to one another. I've found it handy for arranging windows that have
scrollbars since it's easy to tell it to place the scrollbars all the
way on the right and bottom and then have another widget take up the
rest of the window.

There are more details about how to use the geometry managers in
Fredrik Lundh's excellent An Introduction to Tkinter:

http://www.pythonware.com/library/tkinter/introduction/index.htm

Regards,
Matt



More information about the Python-list mailing list