Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: [Tkx] Buffering/Updating issue for text element

by Gangabass (Priest)
on Aug 28, 2010 at 00:19 UTC ( #857789=note: print w/ replies, xml ) Need Help??


in reply to Re: [Tkx] Buffering/Updating issue for text element
in thread [Tkx] Buffering/Updating issue for text element

Thanks for Tkx::repeat but i use sleep only to show the issue. In real code i have HTTP request and text insert after it.


Comment on Re^2: [Tkx] Buffering/Updating issue for text element
Select or Download Code
Re^3: [Tkx] Buffering/Updating issue for text element
by zentara (Archbishop) on Aug 28, 2010 at 11:46 UTC
    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.

    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
      Isn't that a pirate site?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://857789]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-10-24 08:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls