#!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new(); $mw-> geometry("400x100"); $mw -> configure(-background => "cyan", -foreground => "lightblue" ); my ($var, $var1); my $opt = $mw->Optionmenu( -background => "lightgreen", -options => [[jan=>1], [feb=>2], [mar=>3], [apr=>4]], -variable => \$var, )->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"); my $opt1 = $mw->Optionmenu( -background => "lightgreen", -options => [qw(test1 test2 test3)], -variable => \$var1, -state => 'disabled', )->pack; # must configure the $opt command AFTER $opt1 gets created $opt->configure(-command => sub{ print "got: ", shift, "\n"; $opt->configure(-state => 'disabled'); $opt1->configure(-state => 'normal'); }); $opt1->configure( -command => sub{ $opt1->configure(-state => 'disabled'); $exit_but->configure(-state => 'normal'); }); MainLoop;
In reply to Re^5: How to disable the buttons
by zentara
in thread How to disable the buttons
by vr786
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |