www.gibmonks.com




  Previous section   Next section

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 23.  The Pack Geometry Manager


Packer Summary

Keep these rules in mind about the packer:

  • Pack vertically (-side top and -side bottom) or horizontally (-side left and -side right) within a frame. Only rarely will a different mixture of packing directions work out the way you want. Add frames to build more complex structures.

  • By default, the packer puts widgets into their parent frame, and the parent frame must be created before the children that are packed into it.

  • If you put widgets into other relatives, remember to create the frames first so the frames stay underneath the widgets packed into them.

  • By default, the packer ignores -width and -height attributes of frames that have widgets packed inside them. It shrinks frames to be just big enough to allow for its border width and to hold the widgets inside them. Use pack propagate to turn off the shrink-wrap behavior.

  • The packer distinguishes between packing space and display space. A widget's display might not take up all the packing space allocated to it.

  • The -fill option causes the display to fill up the packing space in the X or Y directions, or both.

  • The -expand true option causes the packing space to expand into any room in the packing cavity that is otherwise unclaimed. If more than one widget in the same frame wants to expand, then they share the extra space.

  • The -ipadx and -ipady options allocate more display space inside the border, if possible.

  • The -padx and -pady options allocate more packing space outside the border, if possible. This space is never filled by the widget's display.

The pack Command

Table 23-1 summarizes the pack command. Table 23-2 summarizes the packing options for a widget. These are set with the pack configure command, and the current settings are returned by the pack info command:

Table 23-1. The pack command.
pack win ?win ..? ?options?This is just like pack configure.
pack configure win ?win ...? ?options?Packs one or more widgets according to the options, which are given in Table 23-2.
pack forget win ?win...?Unpacks the specified windows.
pack info winReturns the packing parameters of win.
pack propagate win ?bool?Queries or sets the geometry propagation of win, which has other widgets packed inside it.
pack slaves winReturns the list of widgets managed by win.

Table 23-2. Packing options.
-after winPacks after win in the packing order.
-anchor anchorAnchors: center, n, ne, e, se, s, sw, w, or nw.
-before winPacks before win in the packing order.
-expand booleanControls expansion into the unclaimed packing cavity.
-fill styleControls fill of packing space. Style: x, y, both, or none.
-in winPacks inside win.
-ipadx amountHorizontal internal padding, in screen units.
-ipady amountVertical internal padding, in screen units.
-padx amountHorizontal external padding, in screen units.
-pady amountVertical external padding, in screen units.
-side sideSides: top, right, bottom, or left.


      Previous section   Next section
    Top