#!/usr/bin/perl use Tk; $mw = MainWindow->new(-title => "Testing Stop Button\n"); my $toolbar = $mw->Frame->pack(-side => 'left'); $button_run = $toolbar->Button(-text => "RUN", -command => sub{ $mw->Busy(-recurse => 1, -cursor => 'watch'); $button_run->configure(-state => 'disabled'); $button_stop->configure(-state => 'normal');}) ->pack(-side => 'left'); $button_stop = $toolbar->Button(-text => "STOP", -command => sub{ print "sub called, not Click_stop\n"; $stop_spyglass = 1; $button_stop->configure(-state => 'disabled');}, -state => 'disabled') ->pack(-side => 'left'); $button_stop->bind( '', \&Leave_stop); $button_stop->bind('', \&Enter_stop); $button_stop->bind('', \&Click_stop); sub Enter_stop { print "Enter_stop ", $button_stop->cget('-state'), "\n"; if ($button_stop->cget('-state') eq 'active' ){ $mw->Unbusy(); } } sub Leave_stop { print "Leave_stop ", $button_stop->cget('-state'), "\n"; if ($button_stop->cget('-state') eq 'normal'){ $mw->Busy(-recurse => -1, -cursor => 'watch'); } } sub Click_stop{ print "Click_stop ", $button_stop->cget('-state'), "\n"; if ($button_stop->cget('-state') eq ('active')){ $stop_spyglass = 1; $button_stop->configure(-state => 'disabled'); $button_run->configure(-state => 'normal'); } } MainLoop;