The
grid geometry manager is definitely the way to go with a layout like that. By the way, with regular grids like that you can also take advantage of
grid's ability to grid an entire row at a time:
Code:
grid .b1 .b2 .b3 -padx 4 -pady 2
grid .b4 .b5 .b6 -padx 4 -pady 2
With each
grid command, you can list all of the widgets to appear on a given row in the order that you want them to appear. Each subsequent
grid command of this type creates a new row in the grid. Any gridding options (the
-padx and
-pady settings in this case) are applied to all widgets in that row. You can actually come up with some pretty sophisticated layouts with this shortcut. Try this:
Code:
option add *font {Helvetica 24 bold}
label .a -text "A" -background red
label .b -text "B" -background blue
label .c -text "C" -background green
label .d -text "D" -background yellow
label .e -text "E" -background orange
grid .a - .b -sticky nsew
grid .c .d ^ -sticky nsew
grid ^ .e - -sticky nsew
Of course, gridding by specific row and column like
ulis did gives you control over the individual gridding options of each specific widget.
By the way, you can achieve the 2-row layout originally asked for using only
pack, but it requires frames.
By the way, remember that you can't combine
pack and
grid within a single container. Bad things happen if you try. (Usually, the window doesn't appear, but your CPU time gets chewed up by the two geometry managers fighting with each other.) Within a given toplevel or frame, you must choose either
pack or
grid to lay out all of its immediate children. But that doesn't stop you from using
pack to arrange the widgets in a toplevel, and then using
grid to lay out the widgets in a frame inside of that window. - Ken Jones, President, ken@avia-training.com
Avia Training and Consulting,
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax