The standard behavior of frames and toplevels when using
pack and
grid is to "shrinkwrap" as tightly as possible around their contents without actually squashing the contents. In other words, the contents of a frame or toplevel determines its size. (Unless the window manager overrides that preference -- either because the "preferred" size of the window is too large for display or because the user manually resized the window.)
This is usually the desired behavior. It usually doesn't look very good to have some widgets floating in a sea of empty space. And if all you want is a little extra margin around some of the widgets, simply use the
-padx and
-pady options when you
pack or
grid the widgets. And I suspect that this is the case in your example, as when you pack the frame, you're packing it with
-expand yes and
-fill x, which is explicitly telling
pack that you want to override the default size of the indicated widget. (As an aside, you really don't want the
-expand yes is this example. The
-fill x accomplishes your goal of causing the frame to fill its packing space horizontally.)
In those rare situations where you really do want to fix the size of a frame (or labelframe), you need to tell
pack or
grid not to "propagate" the geometries of the children to the containing frame. If you're using
pack, turn off propagation with:
Code:
pack propagate .menuframe 0
If you're using
grid, turn off propagation with:
Code:
grid propagate .menuframe 0
As another aside, I notice that you're using the old technique for creating a menubar. This method has been obsolete since Tcl/Tk 8.0 (which also introduced native menubar support on Macintosh and Windows platforms). Although your approach still works, the preferred method is as follows:
Code:
# Create a menu widget to act as the window's menubar
menu .mbar
# Associate the menu as the window's menubar
. configure -menu .mbar
# Create a couple of submenus, disabling the "tear-off"
# feature on each of them.
menu .mbar.org -tearoff 0
menu .mbar.acc -tearoff 0
# Add them to the menubar, providing "Alt-style" keyboard
# accelerators simply by indication which character in
# the label to underline.
.mbar add cascade -label "Organise Item" -underline 0 -menu .mbar.org
.mbar add cascade -label "Access" -underline 0 -menu .mbar.acc
# Add some commands to the "Organise Item" menu. Are you
# sure you don't want to call this "File" like most other
# applications?
.mbar.org add command -label "Open..." -underline 0 -command {openFile}
.mbar.org add command -label "Save..." -underline 0 -command {saveFile}
For more information on menus, you might want to check out the Tcl'ers Wiki (
perhaps starting with the page "menu,"
and then continuing to some of the other menu-related pages as found by this search,
- 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