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

Re: Re: Progress Bars TK::ProgressBars First time trying it..

by Rhodium (Scribe)
on Apr 22, 2002 at 20:01 UTC ( [id://161141]=note: print w/replies, xml ) Need Help??


in reply to Re: Progress Bars TK::ProgressBars First time trying it..
in thread Progress Bars TK::ProgressBars First time trying it..

Hi {NULE}
<pr>Thanks a lot!! Here is what I came up with. Please comment on this!
<pr>
#!/usr/local/bin/perl use strict; use Tk; use Tk::DialogBox; use Tk::ProgressBar; my (@joblist, $job, $pid); # Get a list of all jobs currently running.. chdir(); open (IN, ".dractrack") or die "Can't open .dracktrack for input $!\n" +; while (<IN>){ chomp; push (@joblist, $_); } close IN; if (@joblist=""){print" dractrack - Nothing currently in the que!\n";} # For each new job create a window and display the stats foreach $job ( @joblist) { if( $pid = fork ) { } elsif( defined $pid ) { my %drac; ($drac{type},$drac{primary},$drac{rundir},$drac{printfile},$drac{h +ostname},$drac{stages}) = split / /, $job , 6; my $MW = new MainWindow(-title => "Vampire $drac{type} : $drac{pri +mary}"); my $progress = $MW->ProgressBar( -width => 25, -length => 300, -borderwidth => 2, -relief => 'flat', -width => 20, -padx => 2, -pady => 2, -colors => [0 => 'green', .8*$drac{stages}=>'yellow' , .9*$dra +c{stages} => 'red'], -resolution => 1, -blocks => 100, -anchor => "w", -from => 0, -to => $drac{stages}, )->pack(-fill=>"x"); my $stats = $MW->Label(-text=>"Type:$drac{type} Cell: $drac{prim +ary} Host: $drac{hostname} Total Stages: $drac{stages}", -font => '-b&h-lucida sans typewriter-medium-*-*-*-*-*-*-*-*-* +-*-*', -relief=>"sunken", -borderwidth=>2, -anchor=>"w")->pack; &CheckStage( $MW, $progress, $drac{rundir}, $drac{printfile}, $dra +c{stages}); MainLoop; exit; }else { die "Can't fork: $!"; } } # Delete .dractrack dir chdir(); open (DRACNEW, ">>.dracnew") or die "I think dracktrack is running"; rename (".dracnew", ".dractrack") or die "Can't replace .dracktrack.." +; sub CheckStage { my ($MW, $progress, $path, $log, $stages) = @_; my @lstage = 0; while ($lstage[3] < $stages){ open( LOG, "$path$log".".log" ) or die "Cannot open $path$log.log for input: $!\n"; while( <LOG> ) { chomp $_; next if ($_ !~ m/AT STAGE:/); @lstage = split /\s+/, $_; } close LOG; $progress->value($lstage[3]); $MW->update; sleep(1); } $MW->destroy; }

Once again thanks!


Rhodium

The <it>seeker</it> of perl wisdom.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-25 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found