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

Re^3: Entry widget with explicit submit button

by choroba (Canon)
on Feb 15, 2013 at 17:45 UTC ( #1018922=note: print w/ replies, xml ) Need Help??


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

Such a functionality does not exist. You have to create a normal Tk::Button and implement the logic yourself in its -command.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re^3: Entry widget with explicit submit button
Download Code
Re^4: Entry widget with explicit submit button
by amiksingh (Initiate) on Feb 15, 2013 at 18:04 UTC
    okay, but I can't think of a logic because -textvariable of entry widget is changed on the go (as and when user types/changes something). So, how do I revert back to original data on a call from -command of button? (I guess that should have been my exact question, Sorry!)
      it simple, you keep track of the changes
      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://1018922]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2015-07-02 23:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls