Silly question of the day:
I am writing a relatively simple perl program to show a graphical menu of source, exclusions, and destination directory. When the user clicks the Sync button, it copies everything from source to destination.
I would like to display a progress bar for the process . . perhaps refreshing itself each time it starts a new directory. As it stands I don't have a bloody clue how to do this (I am assuming the use of Tk::ProgressBar).
Here is the relevant section where the code should go:
foreach my $dir (@SOURCE) {
next if ($dir eq any(@exclusion_list));
my $mw = MainWindow->new; # Don't use existing window.
my $cmd = "cp -a $home_value\/$dir $storage";
while (system($cmd)) {
my $progress = $mw->ProgressBar(
-width => 200,
-height => 20,
-from => 0,
-to => 100,
-blocks => 10,
-colors => [0, 'green', 50, 'yellow' , 80, 'red'],
-variable => \$percent_done
);
}
}
Obviously this is rudimentary and wrong. i.e I know I somehow need feedback from the system call, and I need to use it to feed the $percent_done, and I also need to know how to "refresh" when the next directory is started. Can anyone provide me with a pointer in the right direction?
What does this little button do . .<Click>;
"USER HAS SIGNED OFF FOR THE DAY"
Edited by planetscape - changed pre to code tags
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.