vr786 has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, I am designed some GUI, there i need to disable and enable the buttons and optionmenus , if i selects one in option-menu the second button should get active till then it should be disable, how can i do it........can you please help me, here is some code ....
#!/usr/bin/perl -w use Tk; my $mw = MainWindow->new(); $mw-> geometry("400x100"); $mw -> configure( -background => "cyan", -foreground => "lightblue" ); my ($var, $tvar); my $opt = $mw->Optionmenu( -background => "lightgreen", -options => [[jan=>1], [feb=>2], [mar=>3], [apr=>4]], -command => sub { print "got: ", shift, "\n" }, -variable => \$var, -textvariable => \$tvar )->pack; $opt->addOptions([may=>5],[jun=>6],[jul=>7],[aug=>8]); my $f = $mw->Frame(-relief=>'groove', -borderwidth => 2)->pack; $f->Label(-textvariable=>\$tvar)->pack(-side => 'left'); $f->Label(-text => " -> ")->pack(-side => 'left'); $f->Label(-textvariable=>\$var)->pack(-side => 'left'); $mw->Button(-text=>'Exit', -command=>sub{$mw->destroy})->pack; my $opt1 = $mw->Optionmenu( -background => "lightgreen", -options => [qw(test1 test2 test3)], -command => sub { print "got: ", shift, "\n" }, # -variable => \$var, #-textvariable => \$tvar )->pack; MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to disable the buttons
by kcott (Archbishop) on Nov 03, 2010 at 15:11 UTC | |
by vr786 (Sexton) on Nov 04, 2010 at 05:11 UTC | |
by kcott (Archbishop) on Nov 04, 2010 at 06:19 UTC | |
by vr786 (Sexton) on Nov 04, 2010 at 07:21 UTC | |
by zentara (Cardinal) on Nov 04, 2010 at 11:37 UTC |