in reply to Re: Tk vs Tkx for -validatecommand
in thread Tk vs Tkx for -validatecommand
I tried the following which includes the callback. It isn't working properly. Does anyone see the problem? Thanks!
#! perl use strict; use warnings; use Tkx; my $value; my $mw = Tkx::widget->new("."); my $ent = $mw->new_entry(-textvariable => \$value,-validate => 'key')- +>g_pack(); $ent->configure( -validatecommand => [sub { $_[0] =~ /^(?:|-|\d+|-\d+)$ +/ }, Tkx::Ev('%P'), $ent], -invalidcommand => \&lam_num_error); my $print_button = $mw->new_button(-text => "Print", -command => \&printx, -font => "ansi 10 bold")->g_pack(); my $reset_frm = $mw->new_frame(); $reset_frm->g_pack(-fill => 'both'); my $reset_button = $reset_frm->new_button(-text => "Reset", -command => \&do_reset, -font => "ansi 10 bold")->g_p +ack(); Tkx::MainLoop(); sub printx { print $value unless $value eq '-'; } sub do_reset { $ent->delete(0, 'end'); } sub lam_num_error { Tkx::tk___mmessageBox(-message => "The input must be an integer.") +; } __END__
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Tk vs Tkx for -validatecommand
by Anonymous Monk on Sep 19, 2012 at 18:42 UTC | |
by shortyfw06 (Beadle) on Sep 19, 2012 at 19:40 UTC | |
by Anonymous Monk on Sep 19, 2012 at 20:00 UTC | |
by shortyfw06 (Beadle) on Sep 20, 2012 at 18:50 UTC | |
by Anonymous Monk on Sep 20, 2012 at 23:54 UTC | |
|
In Section
Seekers of Perl Wisdom