The pack Geometry Manager
With the pack
geometry manager, widgets cannot overlap or cover each other, either
partially or completely. Once a widget is packed into a window, the
next widget is packed in the remaining space around it. pack
sets up an “allocation rectangle” for
each widget, determined by the dimensions of the parent window and
the positioning of the widgets already packed into it. This means
that the order in which you pack your widgets is very
important.
By default, pack
places
widgets at the top center of the allocation rectangle. However, you
can use options to pack
to
control where a widget is placed and how much padding is placed
around it. Options for pack
are:
-side =>
side
Puts the widget against the specified side of the window. Values for
side
areleft
,right
,top
, andbottom
. The default istop
.-fill =>
direction
Causes the widget to fill the allocation rectangle in the specified direction. Values for
direction
arenone
,x
,y
, andboth
. The default isnone
.-expand =>
boolean
Causes the allocation rectangle to fill the remaining space available in the window. Values are
yes
,no
,1
, and0
. The default is0
(no
).-anchor =>
position
Anchors the widget inside the allocation rectangle. Values for
position
aren
,ne
,e
,se
,s
,sw
,w
,nw
, andcenter
. The default iscenter
.-after =>
$
widget
Puts the widget after another widget in packing order.
-before =>
$
widget
Puts the widget before another widget in packing order.
-in =>
$
window
Packs the widget inside another window ...
Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.