in reply to Re^2: [Tkx] Buffering/Updating issue for text element
in thread [Tkx] Buffering/Updating issue for text element
Not to be picky about it, but don't even use sleep to demonstrate a slowdown..... in a GUI it completely gives you bad behavior.
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
Here is one way to make a non-blocking delay without sleep
#!/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(1000, sub{$var++} ); $loop =1; while($loop){ $loop++; $mw->waitVariable(\$var); $count++; } DoOneEvent(); }
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: [Tkx] Buffering/Updating issue for text element
by Anonymous Monk on Aug 28, 2010 at 11:52 UTC | |
by zentara (Archbishop) on Aug 28, 2010 at 12:08 UTC |
In Section
Seekers of Perl Wisdom