dannytrannox has asked for the wisdom of the Perl Monks concerning the following question:
Would you please help me on this subject that has driven me crazy. My goal is to make sure the users always enter the word "go " before anything else to be entered in my Entry. For example, "go east" or "go west" is OK. At first, I thought I could do:
-validatecommand => ( $_1 =~ /^go / ) ;
But it won't work. It looks like -validatecommand doesnot like to match the whole word of "go".
Is there any way in Perl Tk that allows us to validate string that the users enter in Entry box?
For your reference, my simple code is below:
Thanks very much for your help,require Tk; use Tk; $mw = MainWindow->new(); $mw->Entry( -textvariable => \$content , -validate => 'key' , -validatecommand => ( $_[1] =~ /^go / ), -invalidcommand => sub { print "ERROR.\n", $mw->bell() } ) +->pack() ; MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to use validatecommand for string checking
by jdporter (Paladin) on Aug 25, 2007 at 01:05 UTC | |
|
Re: how to use validatecommand for string checking
by zentara (Cardinal) on Aug 25, 2007 at 13:39 UTC | |
by dannytrannox (Initiate) on Aug 27, 2007 at 16:09 UTC | |
by zentara (Cardinal) on Aug 27, 2007 at 18:39 UTC | |
|
Re: how to use validatecommand for string checking
by zentara (Cardinal) on Aug 25, 2007 at 13:32 UTC |