| 1 | package Tkx::LabEntry; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | our $VERSION = '1.10'; | ||
| 5 | |||
| 6 | use base qw(Tkx::widget Tkx::MegaConfig); | ||
| 7 | |||
| 8 | __PACKAGE__->_Mega("tkx_LabEntry"); | ||
| 9 | __PACKAGE__->_Config( | ||
| 10 | -label => [[".lab" => "-text"]], | ||
| 11 | ); | ||
| 12 | |||
| 13 | sub _Populate { | ||
| 14 | my($class, $widget, $path, %opt) = @_; | ||
| 15 | |||
| 16 | my $self = $class->new($path)->_parent->new_frame(-name => $path, -class => "Tkx_LabEntry"); | ||
| 17 | $self->_class($class); | ||
| 18 | |||
| 19 | $self->new_label(-name => "lab", -text => delete $opt{-label})->g_pack(-side => "left"); | ||
| 20 | $self->new_entry(-name => "e", %opt)->g_pack(-side => "left", -fill => "both", -expand => 1); | ||
| 21 | |||
| 22 | $self; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub _mpath { | ||
| 26 | my $self = shift; | ||
| 27 | "$self.e"; | ||
| 28 | } | ||
| 29 | |||
| 30 | 1; | ||
| 31 | |||
| 32 | =head1 NAME | ||
| 33 | |||
| 34 | Tkx::LabEntry - Labeled entry widget | ||
| 35 | |||
| 36 | =head1 SYNOPSIS | ||
| 37 | |||
| 38 | use Tkx; | ||
| 39 | use Tkx::LabEntry; | ||
| 40 | |||
| 41 | my $mw = Tkx::widget->new("."); | ||
| 42 | |||
| 43 | my $e = $mw->new_tkx_LabEntry(-label => "Name"); | ||
| 44 | $e->g_pack; | ||
| 45 | |||
| 46 | my $b = $mw->new_button( | ||
| 47 | -text => "Done", | ||
| 48 | -command => sub { | ||
| 49 | print $e->get, "\n"; | ||
| 50 | $mw->g_destroy; | ||
| 51 | }, | ||
| 52 | ); | ||
| 53 | $b->g_pack; | ||
| 54 | |||
| 55 | Tkx::MainLoop(); | ||
| 56 | |||
| 57 | =head1 DESCRIPTION | ||
| 58 | |||
| 59 | The C<Tkx::LabEntry> module implements a trivial megawidget. Its main | ||
| 60 | purpose is to demonstrate how to use the C<Tkx::MegaConfig> baseclass. | ||
| 61 | |||
| 62 | Once the C<Tkx::LabEntry> module has been loaded, then its widgets | ||
| 63 | can be constructed in the normal way using the C<tkx_LabEntry> name. | ||
| 64 | Besides having a label (whose text can be accessed with the C<-label> | ||
| 65 | configuration option), these widgets behave exactly like an C<entry> | ||
| 66 | would. | ||
| 67 | |||
| 68 | =head1 LICENSE | ||
| 69 | |||
| 70 | This library is free software; you can redistribute it and/or modify | ||
| 71 | it under the same terms as Perl itself. | ||
| 72 | |||
| 73 | Copyright 2005 ActiveState. All rights reserved. | ||
| 74 | |||
| 75 | =head1 SEE ALSO | ||
| 76 | |||
| 77 | The source code of Tkx::LabEntry. | ||
| 78 | |||
| 79 | L<Tkx::MegaConfig>, L<Tkx> |