| Tkx documentation | Contained in the Tkx distribution. |
Tkx::LabEntry - Labeled entry widget
use Tkx;
use Tkx::LabEntry;
my $mw = Tkx::widget->new(".");
my $e = $mw->new_tkx_LabEntry(-label => "Name");
$e->g_pack;
my $b = $mw->new_button(
-text => "Done",
-command => sub {
print $e->get, "\n";
$mw->g_destroy;
},
);
$b->g_pack;
Tkx::MainLoop();
The Tkx::LabEntry module implements a trivial megawidget. Its main
purpose is to demonstrate how to use the Tkx::MegaConfig baseclass.
Once the Tkx::LabEntry module has been loaded, then its widgets
can be constructed in the normal way using the tkx_LabEntry name.
Besides having a label (whose text can be accessed with the -label
configuration option), these widgets behave exactly like an entry
would.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright 2005 ActiveState. All rights reserved.
The source code of Tkx::LabEntry.
| Tkx documentation | Contained in the Tkx distribution. |
package Tkx::LabEntry; use base qw(Tkx::widget Tkx::MegaConfig); __PACKAGE__->_Mega("tkx_LabEntry"); __PACKAGE__->_Config( -label => [[".lab" => "-text"]], ); sub _Populate { my($class, $widget, $path, %opt) = @_; my $self = $class->new($path)->_parent->new_frame(-name => $path, -class => "Tkx_LabEntry"); $self->_class($class); $self->new_label(-name => "lab", -text => delete $opt{-label})->g_pack(-side => "left"); $self->new_entry(-name => "e", %opt)->g_pack(-side => "left", -fill => "both", -expand => 1); $self; } sub _mpath { my $self = shift; "$self.e"; } 1;