The New PerlTk.org - Label Frames
www.mamboteam.com
The New PerlTk.org  
Home
Monday, 01 September 2014
 
 
Main Menu
Home
Perl/Tk Widgets
Articles
Scripts
Useful Tips
Links
Contact Us
Search
FAQs
Login Form
Username

Password

Remember me
Forgotten your password?
No account yet? Create one
Label Frames PDF Print E-mail
Written by Ala Qumsieh   
It is often necessary to visually group together a collection of widgets that are functionally related, and give them a common label. You can do that using a label frame.

NOTE:
In pTk version 800.024 and before, you were stuck with Tk::LabFrame.
In pTk version 804 and beyond, Tk::Labelframe was introduced which is a much better widget than its predecessor.

A typical label frame looks like this:

Image


Note that contrary to the module's name, you can use any widget instead of the label. This is only possible with Tk::Labelframe and NOT with Tk::LabFrame. In the example above, a Checkbutton was used that allows the whole Labelframe widget to be disabled when the checkbutton is unchecked.

The code for producing something like the image above would be:

my $cb = $mw->Checkbutton(-text    => 'Enable',
                          -command => \&enableSub);
my $frame = $mw->Labelframe(-labelwidget => $cb,
                           )->pack(qw/-side top -fill x/);
$frame->Checkbutton(-text => $_,
                    -anchor => 'w',
                    )->pack(qw/-fill both -expand 1/)
    for qw/square circle octagon/;
 
Top! Top!