Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^8: Tk vs Tkx for -validatecommand

by shortyfw06 (Beadle)
on Oct 29, 2012 at 13:44 UTC ( #1001360=note: print w/replies, xml ) Need Help??

in reply to Re^7: Tk vs Tkx for -validatecommand
in thread Tk vs Tkx for -validatecommand

Anonymous Monk, I know you're going to be upset that I still haven't figured this out. If you could possibly give me another hint or resource for solving this, I'd really appreciate it. Here is the latest attempt.

#! perl use strict; use warnings; use diagnostics; use Carp qw(cluck); use Tkx; use B::Deparse; #use YAPE::Explain; my $value; my $mw = Tkx::widget->new("."); my $frame = $mw -> new_frame(); $frame->g_pack(); my $ent = $frame ->new_entry(-textvariable => \$value); $ent->g_pack(); chomp $ent; print ">>>$ent<<<\n"; print "$ent\n"; $ent->configure(-validatecommand => [sub { $_[0] =~ /^(?:|-|\d+|-\d+)$ +/ }, Tkx::Ev('%P'), $ent], -invalidcommand => [\&lam_num_error,Tkx::Ev('%P'), $ent]); my $print_button = $frame->new_button(-text => "Print", -command => \&printx, -font => "ansi 10 bold"); $print_button->g_pack(); chomp $print_button; print ">>>$print_button<<<\n"; print "$print_button\n"; 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"); $reset_button->g_pack(); chomp $reset_button; print ">>>$reset_button<<<\n"; print "$reset_button\n"; cluck ("$reset_button"); 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.") +; }

Replies are listed 'Best First'.
Re^9: Tk vs Tkx for -validatecommand
by Anonymous Monk on Oct 30, 2012 at 05:26 UTC
    Take this idea  print ">>>$ent<<<\n"; and apply it to all callbacks

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001360]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2019-02-18 12:13 GMT
Find Nodes?
    Voting Booth?
    I use postfix dereferencing ...

    Results (100 votes). Check out past polls.