[Tutor] moving from pack to grid in tkinter

Alan Gauld alan.gauld at btinternet.com
Mon Nov 27 19:55:02 CET 2006


"Tony Cappellini" <cappy2112 at gmail.com> wrote

>>>
> But i'm trying to get away from pack() and use grid()

There's no good reason not to use pack where it makes sense.
You can mix n match provided you keep it consistent within a
single container(usually a frame)

Grid is best where the controls conform to a grid, typically
when laid out across the Frame.
Pack is a natural where you want to stack things on
top of each other.

Typically I use pack for the frames in the main window
and grid for the widgets inside each frame.

A status bar is most naturally expressed as a frame at
the bottom of your window containing a label widget so
I'd use pack for it.

You can force it wirth grid by picking a very large number
but its a bit of a kluge in my view.

>>>f there is nothing in a row, the row will have a height of zero. 
>>>So
> So how does one place a label (or any other widget) at the bottom 
> row of a
> screen using grid()?

Are you using grid on your top window or on a frame within that?
It sounds like maybe the former. Try creating a frame and
gridding it into the main window. Then grid your widgets
inside the Frame. (I haven't tried this but it sounds like a 
possibility!)
That way the window should shrink to fit the frame...
.
> Well thanks anyway. The pdf has really confused me.
> Is there an official tkinter.org doc reference or something?

Have you checked the Tkinter page in the Python.org web site?
Also the Tcl/Tk documentation gives a fairly definitive description
of how things work, albeit expressed in Tcl speak

HTH,

Alan G. 




More information about the Tutor mailing list