in reply to How to force Perl/Tk to update the GUI?

...ooh, you are missing the point of the eventloop..... you cannot put sleep into an eventloop gui. ..... what is happening, is that nothing gets displayed until the MainLoop line is reached....so when you write gui programs, remember...nothing gets displayed until the mainloop line is executed..... sleep interferes with mainloops....so setup timers
#!/usr/bin/perl use warnings; use strict; use Tk; my $toggle; my $mw = new MainWindow; my $button = $mw->Button(-text => "RUN ", -bg => 'white', -command => \&toggle)->pack(-expand=>1, -fill=>'both'); my $timer = $mw->repeat(1000,\&toggle); #notice the difference #my $timer= $mw->after(1000,\&toggle); MainLoop; sub toggle{ print $button->cget('-text'),"\n"; if ( $button->cget('-text') eq 'RUN '){ $button->configure(-text => 'STOP', -bg => 'yellow', -activebackground => 'yellow', -highlightbackground => 'yellow' ); $toggle = 1; } elsif ( $button->cget('-text') eq 'STOP'){ $button->configure(-text => 'RUN ', -bg => 'white', -activebackground => 'white', -highlightbackground => 'white' ); $toggle = 0; } }

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