in reply to Progress Bar

Here's an graphical example using Tk. I wrote this to measure the progress of a compile (count's .o's in the build directory), but it can easily be tweakified for your own purposes.
Enjoy.
use Tk; sub tick; $MYBUILDDIR="c:\\build"; #Dont forget to backslash the backslashes $total_objects = 303; #Number of object files a full build would creat +e $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($MYBUILDIR . "*.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;

Replies are listed 'Best First'.
Re: Re: Progress Bar
by JojoLinkyBob (Scribe) on Jan 09, 2002 at 08:25 UTC
    Oops, I posted anonymously by mistaked. Oh well, no biggy.
    =~Desertcoder