1pack(3)               User Contributed Perl Documentation              pack(3)
2
3
4

NAME

6       Tk::pack - Geometry manager that packs around edges of cavity
7

SYNOPSIS

9        $widget->pack?(args)?
10
11        $widget->packOption?(args)?
12

DESCRIPTION

14       The pack method is used to communicate with the packer, a geometry man‐
15       ager that arranges the children of a parent by packing them in order
16       around the edges of the parent.
17
18       In this perl port of Tk it is normal to pack widgets one-at-a-time
19       using the widget object to be packed to invoke a method call.  This is
20       a slight distortion of underlying Tk interface (which can handle lists
21       of windows to one pack method call) but has proven effective in prac‐
22       tice.
23
24       The pack method can have any of several forms, depending on Option:
25
26       $slave->pack?(options)?
27           The options consist of pairs of arguments that specify how to man‐
28           age the slave.  See "THE PACKER ALGORITHM" below for details on how
29           the options are used by the packer.  The following options are sup‐
30           ported:
31
32           -after => $other
33                   $other must be another window.  Use its master as the mas‐
34                   ter for the slave, and insert the slave just after $other
35                   in the packing order.
36
37           -anchor => anchor
38                   Anchor must be a valid anchor position such as n or sw; it
39                   specifies where to position each slave in its parcel.
40                   Defaults to center.
41
42           -before => $other
43                   $other must be another window.  Use its master as the mas‐
44                   ter for the slave, and insert the slave just before $other
45                   in the packing order.
46
47           -expand => boolean
48                   Specifies whether the slave should be expanded to consume
49                   extra space in their master.  Boolean may have any proper
50                   boolean value, such as 1 or no.  Defaults to 0.
51
52           -fill => style
53                   If a slave's parcel is larger than its requested dimen‐
54                   sions, this option may be used to stretch the slave.  Style
55                   must have one of the following values:
56
57                   none        Give the slave its requested dimensions plus
58                               any internal padding requested with -ipadx or
59                               -ipady.  This is the default.
60
61                   x           Stretch the slave horizontally to fill the
62                               entire width of its parcel (except leave exter‐
63                               nal padding as specified by -padx).
64
65                   y           Stretch the slave vertically to fill the entire
66                               height of its parcel (except leave external
67                               padding as specified by -pady).
68
69                   both        Stretch the slave both horizontally and verti‐
70                               cally.
71
72           -in => $master
73                   Insert the slave(s) at the end of the packing order for the
74                   master window given by $master.
75
76           -ipadx => amount
77                   Amount specifies how much horizontal internal padding to
78                   leave on each side of the slave(s).  Amount must be a valid
79                   screen distance, such as 2 or .5c.  It defaults to 0.
80
81           -ipady => amount
82                   Amount specifies how much vertical internal padding to
83                   leave on each side of the slave(s).  Amount  defaults to 0.
84
85           -padx => amount
86                   Amount specifies how much horizontal external padding to
87                   leave on each side of the slave(s).  Amount defaults to 0.
88
89           -pady => amount
90                   Amount specifies how much vertical external padding to
91                   leave on each side of the slave(s).  Amount defaults to 0.
92
93           -side => side
94                   Specifies which side of the master the slave(s) will be
95                   packed against.  Must be left, right, top, or bottom.
96                   Defaults to top.
97
98       If no -in, -after or -before option is specified then slave will be
99       inserted at the end of the packing list for its parent unless it is
100       already managed by the packer (in which case it will be left where it
101       is).  If one of these options is specified then slave will be inserted
102       at the specified point.  If the slave are already managed by the geome‐
103       try manager then any unspecified options for them retain their previous
104       values rather than receiving default values.
105
106       $slave->packConfigure?(options)?
107           Same as pack.
108
109       $slave->packForget
110           Removes slave from the packing order for its master and unmaps its
111           window.  The slave will no longer be managed by the packer.
112
113       $slave->packInfo
114           Returns a list whose elements are the current configuration state
115           of the slave given by $slave in the same option-value form that
116           might be specified to packConfigure.  The first two elements of the
117           list are ``-in=>$master'' where $master is the slave's master.
118
119       $master->packPropagate?(boolean)?
120           If boolean has a true boolean value such as 1 or on then propaga‐
121           tion is enabled for $master, (see "GEOMETRY PROPAGATION" below).
122           If boolean has a false boolean value then propagation is disabled
123           for $master.  In either of these cases an empty string is returned.
124           If boolean is omitted then the method returns 0 or 1 to indicate
125           whether propagation is currently enabled for $master.  Propagation
126           is enabled by default.
127
128       $master->packSlaves
129           Returns a list of all of the slaves in the packing order for $mas‐
130           ter.  The order of the slaves in the list is the same as their
131           order in the packing order.  If $master has no slaves then an empty
132           list/string is returned in array/scalar context, respectively
133

THE PACKER ALGORITHM

135       For each master the packer maintains an ordered list of slaves called
136       the packing list.  The -in, -after, and -before configuration options
137       are used to specify the master for each slave and the slave's position
138       in the packing list.  If none of these options is given for a slave
139       then the slave is added to the end of the packing list for its parent.
140
141       The packer arranges the slaves for a master by scanning the packing
142       list in order.  At the time it processes each slave, a rectangular area
143       within the master is still unallocated.  This area is called the cav‐
144       ity;  for the first slave it is the entire area of the master.
145
146       For each slave the packer carries out the following steps:
147
148       [1] The packer allocates a rectangular parcel for the slave along the
149           side of the cavity given by the slave's -side option.  If the side
150           is top or bottom then the width of the parcel is the width of the
151           cavity and its height is the requested height of the slave plus the
152           -ipady and -pady options.  For the left or right side the height of
153           the parcel is the height of the cavity and the width is the
154           requested width of the slave plus the -ipadx and -padx options.
155           The parcel may be enlarged further because of the -expand option
156           (see "EXPANSION" below)
157
158       [2] The packer chooses the dimensions of the slave.  The width will
159           normally be the slave's requested width plus twice its -ipadx
160           option and the height will normally be the slave's requested height
161           plus twice its -ipady option.  However, if the -fill option is x or
162           both then the width of the slave is expanded to fill the width of
163           the parcel, minus twice the -padx option.  If the -fill option is y
164           or both then the height of the slave is expanded to fill the width
165           of the parcel, minus twice the -pady option.
166
167       [3] The packer positions the slave over its parcel.  If the slave is
168           smaller than the parcel then the -anchor option determines where in
169           the parcel the slave will be placed.  If -padx or -pady is
170           non-zero, then the given amount of external padding will always be
171           left between the slave and the edges of the parcel.
172
173           Once a given slave has been packed, the area of its parcel is sub‐
174           tracted from the cavity, leaving a smaller rectangular cavity for
175           the next slave.  If a slave doesn't use all of its parcel, the
176           unused space in the parcel will not be used by subsequent slaves.
177           If the cavity should become too small to meet the needs of a slave
178           then the slave will be given whatever space is left in the cavity.
179           If the cavity shrinks to zero size, then all remaining slaves on
180           the packing list will be unmapped from the screen until the master
181           window becomes large enough to hold them again.
182

EXPANSION

184       If a master window is so large that there will be extra space left over
185       after all of its slaves have been packed, then the extra space is dis‐
186       tributed uniformly among all of the slaves for which the -expand option
187       is set.  Extra horizontal space is distributed among the expandable
188       slaves whose -side is left or right, and extra vertical space is dis‐
189       tributed among the expandable slaves whose -side is top or bottom.
190

GEOMETRY PROPAGATION

192       The packer normally computes how large a master must be to just exactly
193       meet the needs of its slaves, and it sets the requested width and
194       height of the master to these dimensions.  This causes geometry infor‐
195       mation to propagate up through a window hierarchy to a top-level window
196       so that the entire sub-tree sizes itself to fit the needs of the leaf
197       windows.  However, the packPropagate method may be used to turn off
198       propagation for one or more masters.  If propagation is disabled then
199       the packer will not set the requested width and height of the packer.
200       This may be useful if, for example, you wish for a master window to
201       have a fixed size that you specify.
202

RESTRICTIONS ON MASTER WINDOWS

204       The master for each slave must either be the slave's parent (the
205       default) or a descendant of the slave's parent.  This restriction is
206       necessary to guarantee that the slave can be placed over any part of
207       its master that is visible without danger of the slave being clipped by
208       its parent.
209

PACKING ORDER

211       If the master for a slave is not its parent then you must make sure
212       that the slave is higher in the stacking order than the master.  Other‐
213       wise the master will obscure the slave and it will appear as if the
214       slave hasn't been packed correctly.  The easiest way to make sure the
215       slave is higher than the master is to create the master window first:
216       the most recently created window will be highest in the stacking order.
217       Or, you can use the raise and lower methods to change the stacking
218       order of either the master or the slave.
219

SEE ALSO

221       Tk::form Tk::grid Tk::place
222

KEYWORDS

224       geometry manager, location, packer, parcel, propagation, size
225
226
227
228perl v5.8.8                       2008-02-05                           pack(3)
Impressum