Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: tk Entry validatecommand stops responding

by tybalt89 (Prior)
on Nov 20, 2018 at 13:35 UTC ( #1226070=note: print w/replies, xml ) Need Help??


in reply to tk Entry validatecommand stops responding

Stopped failing for me once I commented out the two ->update calls. They were not needed anyways.

#!/usr/bin/perl # https://perlmonks.org/?node_id=1226054 use strict; use warnings; use Tk; $SIG{__WARN__} = sub { die @_ }; my %mults = ( A => "a", B => "b", '' => '', ); my %Inputs; my %Telltale; sub inline_validate_section { $Inputs{Section} or return 1; $Telltale{Section} or return 1; my $entry = uc(shift); print "$entry\n"; if(defined($mults{$entry}) || !$entry){ $Inputs{Section}->configure(-background => 'lightgrey'); $Telltale{Section}->configure(-text => "$mults{$entry}"); #$Telltale{Section}->update(); } else { $Inputs{Section}->configure(-background => 'red'); $Telltale{Section}->configure(-text => "nope"); #$Telltale{Section}->update(); } return 1; } my $main = MainWindow->new(); $main->geometry('400x100'); # two frames and adjuster my $main_frame = $main->Frame; # right # pack frames $main_frame->pack(qw/-side right -fill both -expand l/); my $vn = "Section"; $main_frame->Label(-text => $vn, -width => 15)->pack(qw/-side left/) +; $Inputs{$vn} = $main_frame->Entry(-validate => 'key', -validatecommand => [\&inline_validate_section], -textvariable => \$vn)->pack(qw/-side left -padx 1 +0 -pady 5 -fill x/); $Telltale{$vn} = $main_frame->Label(-text => "nope", -width => 25)-> +pack(qw/-side left/); MainLoop();

Notice other changes to run under strict and warnings :(

Replies are listed 'Best First'.
Re^2: tk Entry validatecommand stops responding
by cscvrp (Novice) on Nov 20, 2018 at 17:21 UTC
    Thanks for looking at it, I'm curious as to why it does what it does with the ->update in there mostly, glad to see you get the same behavior though. Yes I stripped it down pretty far for the example, but your right it does not hurt to practice like you play.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-05-19 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (72 votes). Check out past polls.

    Notices?