in reply to How to freeze a button while it is in active mode

If $run_all_button->flash() dosn't work, you can make one manually with a timer. See second script below. I'm guessing it flashes once, and so fast you miss it. You may need to add a timer.

As to your button states, look at this script.

#!/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>', \&Leave_stop); $button_stop->bind('<Enter>', \&Enter_stop); $button_stop->bind('<Button-1>', \&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;
and a button flasher
#!/usr/bin/perl use Tk; use strict; my $mw = tkinit; my $button = $mw->Button(-text => 'Push Me')->pack; $button->configure(-command => [\&Invert, $button]); my $button1 = $mw->Button(-text => 'Flashy')->pack; my $timer = $mw->repeat(500,[\&Invert, $button1]); MainLoop; sub Invert { my($w) = @_; $w->configure(-bg => $w->cget('-fg'), -fg => $w->cget('-bg')); }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: How to freeze a button while it is in active mode
by Janish (Sexton) on Jul 18, 2014 at 02:46 UTC

    Thanks Zentara, for again helping me with the sample code ans explanation.. which I really greatful to have your helping hands when I need. I finally manage to get my code done by doing the disabled/normal the button at my subroutine.