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

Re^5: Entry widget with explicit submit button

by 7stud (Deacon)
on Feb 15, 2013 at 20:15 UTC ( #1018965=note: print w/replies, xml ) Need Help??


in reply to Re^4: Entry widget with explicit submit button
in thread Entry widget with explicit submit button

Why are you using a textvariable at all?
use strict; use warnings; use 5.012; use Tk; my $entry_text; my $mw = MainWindow->new; my $entry = $mw->Entry( -text => 'Enter answer here', )->pack; $entry->focus; $entry->selectionRange(0, 'end'); sub my_validator { my $input = $entry->get(); if ($input eq 'hello') { $entry->delete(0, 'end'); $entry->insert(0, 'Try again!'); $entry->selectionRange(0, 'end'); $entry->icursor(0); } else { say "Thanks for the great input!"; $entry_text = $input; say $entry_text; } } $mw->Button( -text => 'Submit', -command => \&my_validator, )->pack; MainLoop;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018965]
help
Chatterbox?
[LanX]: the bets are rather who will leave office first Trump or May
[erix]: Harakiri with a nuke on the white house, that'd clean up the staff there a bit too ;)
[erix]: (sorry, I'm always a bit violent on fridays)
LanX predicts problems for Erix next time he lines up at an US immigration counter
[erix]: but tuesdays just as bad
[erix]: thanks for the heads-up but that's a line-up studiiously avoided :P

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2017-08-18 13:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (302 votes). Check out past polls.

    Notices?