Tkinter pack Problem

Joe Knapka jk.usenet at kneuro.net
Wed Jul 26 12:24:33 EDT 2006


H J van Rooyen wrote:

> Hi,
> 
> I am struggling to get the pack method to do what I intend.
> I am trying to display user input in a seperate window, along with
> a little description of the field, something like this:
> 
>              Current entry
> Company :               entered co. name
> First entry :               entered stuff
> The second entry:     more entered stuff
> Entry number three :  Last entered stuff

You can achieve this with pack(), but only by using
a lot of nested panels:

+-----------------------------------------+
|             Current entry               |
+-----------------------------------------+
+-----------------------------------------+
|Company :               entered co. name |
+-----------------------------------------+
+-----------------------------------------+
|First entry :               entered stuff|
+-----------------------------------------+
+-----------------------------------------+
|The second entry:     more entered stuff |
+-----------------------------------------+
+-----------------------------------------+
|Entry number three :  Last entered stuff |
+-----------------------------------------+

Create the subpanels and pack the labels
into their respective subpanels with side="left"
and the entry fields with side="right"; then
pack all the subpanels into the main window
with side="top". But this is really a PITA,
it would be simpler use grid() as Eric B suggests.
Once you learn grid(), you will probably never
need to use pack() again.

-- JK



More information about the Python-list mailing list