The Pane Widget

The Pane widget is essentially a Frame widget that may be scrolled. Within the Pane, you can pack whatever widgets however you like:

my $pane = $mw->Scrolled(qw/Pane -scrollbars osw/)->pack;

foreach (1 .. 20) {
    $pane->Label(-text => "Label $_")->pack;
}

The previous code produced Figure 23-17.

A Pane widget with a Scrollbar

Figure 23-17. A Pane widget with a Scrollbar

Pane Options

The following options are available for Pane:

-gridded => 'x' | 'y' | 'xy'

Specifies if the top and left edges of the pane should snap to a grid column. This option is useful only if the widgets in the pane are managed by the grid geometry manager.

-sticky => style

If the Pane is larger than its requested dimensions, this option may be used to position (or stretch) the slave widgets within their cavity. style is a string that contains zero or more of the characters n, s, e, or w. Each letter refers to a side (north, south, east, or west) to which the slave sticks. If both n and s (or e and w) are specified, the slave is stretched to fill the entire height (or width) of its cavity.

There are also various methods to position the Pane’s view. See the POD documentation for more information.

Get Mastering Perl/Tk 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.