Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: TK: Repeat and variable from outside

by lamprecht (Friar)
on Apr 04, 2011 at 15:11 UTC ( [id://897341]=note: print w/replies, xml ) Need Help??


in reply to TK: Repeat and variable from outside

Tk's binding the -variable seems to reset it. Workaround is easy: Set the initial value after instantiation of your ProgressBar.

use strict; use warnings; use Tk; use Tk::ProgressBar; my $nb_sec; my $mw = MainWindow->new(-title => 'Progress Bar Example'); $mw->resizable(0,0); my $pb = $mw->ProgressBar(-from => 0, -to => 90, -blocks => 90, -anchor => 'w', -length => 200, -width => 30, -colors => [0,'blue'], -variable => \$nb_sec)->pack(); $mw->Label(-textvariable => \$nb_sec)->pack; $nb_sec = 30; $pb->repeat( 1000 => sub { $nb_sec += 1; $mw->destroy if $nb_sec >= 90; }); MainLoop();

Cheers, Christoph

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2026-04-10 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.