#!/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'); } }