Perl/Tk provides special code that combines a Label with an arbitrary widget, so you can have LabArbitrary widgets. This is fully explained in Chapter 14, "Creating Custom Widgets in Pure Perl/Tk". Perhaps the most common of these labeled widgets is LabEntry. It's configured using standard options, and ordinary options such as -font are directed to the Entry subwidget. To configure the Label subwidget, use options such as -labelFont, -labelBackground, and so on.
There's a special option, -labelPack, that accepts a reference to a list of packer options and controls the relative geometry of the Label and Entry subwidgets. By default, the Label is packed on top of the Entry. If you prefer left-side packing, use -labelPack as in the example below. This example shows how to use a fixed-width font to create a column of aligned LabEntry widgets:
foreach my $item ( ['Copying', \$self->{file}], ['From', \$self->{from}], ['To', \$self->{to}], ['Bytes Copied', \$self->{bytes_msg}], ) { my $l = $item->[0] . ':'; my $le = $cf_frame->LabEntry( -label => ' ' x (13 - length $l) . $l, -labelPack => [qw/-side left -anchor w/], -labelFont => '9x15bold', -relief => 'flat', -state => 'disabled', -textvariable => $item->[1], -width => 35, ); $le->pack(qw/-fill x -expand 1/); }
Please refer to Chapter 14, "Creating Custom Widgets in Pure Perl/Tk" for a complete list of -label options.