in reply to Re^2: Perl/Tk repeat method, callback doesn't work if...
in thread Perl/Tk repeat method, callback doesn't work if...
Here is a little something for you to play with, for waitVariable
#!/usr/bin/perl use warnings; use strict; use Tk; $|=1; my $count = 0; my $loop = 0; my $mw = new MainWindow(); $mw->Label( -textvariable => \$count )->pack; $mw->Button( -text => 'Start', -command => \&long_job ) ->pack( -side => 'left' ); $mw->Button( -text => 'Stop', -command => sub { $loop = 0; print "$cou +nt\n"; } ) ->pack( -side => 'left' ); MainLoop(); sub long_job { my $var; my $timer = $mw->repeat(100, sub{$var++} ); $loop =1; while($loop){ $loop++; $mw->waitVariable(\$var); $count++; } DoOneEvent(); #must call or will block gui }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl/Tk repeat method, callback doesn't work if...
by NewMonkMark (Initiate) on May 19, 2011 at 16:39 UTC | |
by zentara (Cardinal) on May 19, 2011 at 18:10 UTC |