Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to use Tk::StatusBar

by Util (Priest)
on Oct 27, 2008 at 13:16 UTC ( [id://719735]=note: print w/replies, xml ) Need Help??


in reply to How to use Tk::StatusBar

The repeat() call is only there to demo the progress bar; your actual code will probably not need to use repeat() at all. Write your Perl/TK program as normal, but whenever an event occurs that marks a further step toward the completion of the task, update $Progress at the end of that event. For example:
use strict; use warnings; use Tk; use Tk::StatusBar; my $mw = MainWindow->new(); $mw->Label( -text => 'Mission: knock three times' )->pack(); $mw->Button( -text => 'Knock', -command => \&knock )->pack(); my $sb = $mw->StatusBar(); my $Label1 = 'Progress in knocking:'; $sb->addLabel( -textvariable => \$Label1 ); my $Progress = 0; sub knock { print "Knocking\n"; $Progress += 33; $Label1 = 'Done!' if $Progress >= 99; } $sb->addProgressBar( -length => 60, -from => 0, -to => 99, -variable => \$Progress, ); MainLoop();

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-26 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found