Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: tie variable

by AnomalousMonk (Archbishop)
on May 29, 2015 at 22:44 UTC ( [id://1128355]=note: print w/replies, xml ) Need Help??


in reply to tie variable

... wish to display number of characters input to entry in label on each keystroke ...

Here's one approach using entry input validation. I'm sure there are others and better.

c:\@Work\Perl\monks>perl -wMstrict -le "use Tk; use Tk::LabEntry; ;; my $MW = tkinit; ;; my $entrytext = ''; my $le = $MW->LabEntry( -label => 'chars entered so far: 0', -textvariable => \$entrytext, -validate => 'key', -invalidcommand => undef, ); $le->configure( -validatecommand => sub { showcount($le, @_) }, ); $le->pack; ;; MainLoop; ;; print qq{final entry: '$entrytext'}; ;; sub showcount { my ($widget, $newtext, ) = @_; ;; my $label = $widget->cget(-label); $label =~ s{ \d+ \z }{ length $newtext }xmse; $widget->configure(-label => $label); 1; } "


Give a man a fish:  <%-(-(-(-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-24 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found