Ah Yes, I had this problem before, here's a
quick-and-dirty progress bar script that uses and example
#progress bar that monitors a compile,
#by counting .o's periodically
use Tk;
sub tick;
$total_objects = 303;
$progressbar_width = 2*$total_objects;
$progressbar_height = 50;
$timer_interval=10; #in seconds
$MW = MainWindow->new;
$MW->bind('<Control-c>' => \&exit);
$MW->bind('<Control-q>' => \&exit);
$canvas1 = $MW->Canvas(
'-width' => $progressbar_width,
-height => $progressbar_height,
-background => 'black'
) -> pack;
$newval = 10;
$start = $MW->Button(
-text => 'Start',
-command => sub {tick},
);
$start->pack(-side => 'left', -fill => 'both', -expand => 'yes');
sub tick {
# Update the counter every 5 seconds
$MW->after($timer_interval * 1000, \&tick);
$num_objs = @objects = glob("\\as900\\code\\build\\*.o");
print "\n$num_objs out of $total_objects built so far...";
$newval = ($num_objs / $total_objects)*$progressbar_width;
$canvas1->create ('rectangle','0','0',$newval,$progressbar_height,
+-fill=>'red');
}
MainLoop;
This gives you the capability of a timer callback.
Desert coder
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.