http://www.perlmonks.org?node_id=11147647

PilotinControl has asked for the wisdom of the Perl Monks concerning the following question:

Good Evening Monks!

My question is simple. I need to keep a button disabled even though another button is capable of enabling the disabled button. My code is below in its simplest form. In the bigger program a sensor keeps the button disabled even though other buttons in the program can enable the button when the sensor is NOT covered. Thanks in advance.

use Tk; use strict; my $Main = MainWindow->new(); my $Frame = $Main->Frame(); $Frame->pack(); my $Button1 = $Frame->Button(-text=>'One', -command=>\&one); $Button1->pack(); my $Button2 = $Frame->Button(-text=>'Two', -command=>\&two); $Button2->pack(); my $Button3 = $Frame->Button(-text=>'Three', -command=>\&three); $Button3->pack(); my $Button4 = $Frame->Button(-text=>'Four', -command=>\&four); $Button4->pack(); MainLoop(); sub one() { print "Hello\n"; } sub two() { $Button1->configure(-state => "disabled"); print "State Disabled: Only Button Three Can Enable Not Button Four.\n +" } sub three() { $Button1->configure(-state => "normal"); print "State Normal\n"; } sub four() { $Button1->configure(-state => "normal"); print "State Normal\n"; }