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
15       manager 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
22       practice.
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
28           manage the slave.  See "THE PACKER ALGORITHM" below for details on
29           how the options are used by the packer.  The following options are
30           supported:
31
32           -after => $other
33                   $other must be another window.  Use its master as the
34                   master for the slave, and insert the slave just after
35                   $other 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
44                   master for the slave, and insert the slave just before
45                   $other 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
54                   dimensions, this option may be used to stretch the slave.
55                   Style 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
63                               external 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
70                               vertically.
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
103       geometry manager then any unspecified options for them retain their
104       previous 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
121           propagation is enabled for $master, (see "GEOMETRY PROPAGATION"
122           below).  If boolean has a false boolean value then propagation is
123           disabled for $master.  In either of these cases an empty string is
124           returned.  If boolean is omitted then the method returns 0 or 1 to
125           indicate whether propagation is currently enabled for $master.
126           Propagation is enabled by default.
127
128       $master->packSlaves
129           Returns a list of all of the slaves in the packing order for
130           $master.  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
144       cavity;  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 non-
170           zero, then the given amount of external padding will always be left
171           between the slave and the edges of the parcel.
172
173           Once a given slave has been packed, the area of its parcel is
174           subtracted from the cavity, leaving a smaller rectangular cavity
175           for 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
186       distributed uniformly among all of the slaves for which the -expand
187       option is set.  Extra horizontal space is distributed among the
188       expandable slaves whose -side is left or right, and extra vertical
189       space is distributed among the expandable slaves whose -side is top or
190       bottom.
191

GEOMETRY PROPAGATION

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

RESTRICTIONS ON MASTER WINDOWS

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

PACKING ORDER

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

SEE ALSO

222       Tk::form Tk::grid Tk::place
223

KEYWORDS

225       geometry manager, location, packer, parcel, propagation, size
226
227
228
229perl v5.30.1                      2020-01-30                           pack(3)
Impressum