The LabFrame Widget

A LabFrame widget has all the features of a Frame and additionally provides a text label on the 'top', 'bottom', 'left', or 'right' of the Frame. The special placement option 'acrosstop' creates a grooved Frame around the central Frame and puts the label near the northwest corner such that it overlays the groove.

use Tk;
use Tk::LabFrame;
use strict;

my $mw = MainWindow->new(-title => 'LabFrame example')
my $lf = $mw->LabFrame(-label => "This is the label of a LabFrame",
     -labelside => 'acrosstop')->pack;
$lf->Text(qw/-width 40 -height 5/)->pack;
MainLoop;

This code produces the widget shown in Figure 23-14.

A LabFrame widget

Figure 23-14. A LabFrame widget

LabFrame Options

LabFrame supports the same options as the Frame widget, plus:

-label => text

The text of the label to be placed with the Frame

-labelside => 'left' | 'right' | 'top' | 'bottom' | 'acrosstop'

Where to put the label on the frame

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.