my $numentry = $mw->NumEntry( [ option => value ] );with options as described below:
#!perl
# file numentry.pl
use Tk;
use Tk::NumEntry;
use strict;
use warnings;
my $message = 'You have selected nothing yet';
my $value = '';
my $mw = MainWindow->new;
$mw->title('NumEntry');
my $label = $mw->Label(-textvariable => \$message);
my $instruct = $mw->Label(-text => 'Please choose a year');
my $exit = $mw->Button(-text => 'Exit',
                      -command => [$mw => 'destroy']);
my $numentry = $mw->NumEntry(-minvalue => 1990,
                             -maxvalue => 2000,
                             -width => 8,
                             -value => 1995,
                             -textvariable => \$value);
my $show = $mw->Button(-text => 'Show value',
                       -command => sub{$message = "You have selected $value"});
$instruct->pack;
$numentry->pack;
$label->pack;
$show->pack;
$exit->pack;
MainLoop;
Here the value of the NumEntry widget is associated
with the variable $value, and the $show button
can be pressed to display the current value. This
window appears below.
Randy Kobes 2003-11-17