vr786 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I want to validate the fields , i am trying like this but i don't know where iam going wrong please , any one can explain....it.
#!/usr/bin/perl -w use strict; use Tk; my $opt = "0"; my $opt1 = "0"; my $mw = MainWindow->new(); $mw-> geometry("400x100"); $mw -> configure(-background => "cyan", -foreground => "lightblue" ); my ($var, $var1); $opt = $mw->Optionmenu( -background => "lightgreen", -options => [[jan=>1], [feb=>2], [mar=>3], [apr=>4]], -variable => \$var, -command => \&sub_opt, )->pack; $opt->addOptions([may=>5],[jun=>6],[jul=>7],[aug=>8]); my $exit_but = $mw->Button(-text=>'Exit', -command=>sub{ print "Var= $var Var1= $var1\n"; $mw->destroy}, -state => 'disabled', )->pack(-side=>"bottom"); $opt1 = $mw->Optionmenu( -background => "lightgreen", -options => [qw(test1 test2 test3)], -variable => \$var1, -state => 'disabled', -command =>\&sub_opt1, )->pack; MainLoop; sub sub_opt { if($var ne " ") { $opt->configure(-state => 'disabled'); $opt1->configure(-state => 'normal'); } else { $opt -> configure(-state => 'disabled'); } } sub sub_opt1 { if ( $var1 ne " ") { $opt1->configure(-state => 'disabled'); $exit_but->configure(-state =>'normal'); } else { $exit_but->configure(-state => 'disabled'); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: optionmenu configure problem in perl tk
by biohisham (Priest) on Nov 08, 2010 at 08:30 UTC | |
by kcott (Archbishop) on Nov 08, 2010 at 13:21 UTC | |
|
Re: optionmenu configure problem in perl tk
by zentara (Cardinal) on Nov 08, 2010 at 13:24 UTC |