G'day hermes1908,
Welcome to the monastery.
I don't think your users would be too happy having to manually update the download progress by pressing a button. This is really something you'd want to display dynamically. Consider how it's done in a simple text-based scenario (e.g. wget) or in a graphical context such as your browser: you don't need to hit keys or press buttons to see what progress has been made.
When designing a GUI, think about how it's been done previously and how your users would expect it to work. Unless you are intending to present something that is fundamentally different from the norm, stick with the status quo.
Here's a working (albeit barebones) script that simulates 3 files being downloaded simultaneously and shows progress dynamically.
#!/usr/bin/env perl use strict; use warnings; use Tk; use Tk::ProgressBar; my @file_data = ( { name => 'File1', size => 1000 }, { name => 'File2', size => 5000 }, { name => 'File3', size => 2500 }, ); my $mw = MainWindow->new(); $mw->geometry('400x200+50+50'); my $control_F = $mw->Frame()->pack(-side => 'bottom'); $control_F->Button(-text => 'Exit', -command => sub { exit } )->pack(-padx => 5, -pady => 5); my $progress_F = $mw->Frame( )->pack(-padx => 10, -pady => 10, -fill => 'both', -expand => 1); for my $file_datum (@file_data) { my $download_amount = 0; my $download_percent; my $download_F = $progress_F->Frame( )->pack(-padx => 10, -pady => 10, -side => 'top', -fill => 'x' +); $download_F->Label(-text => $file_datum->{name} )->pack(-padx => 5, -side => 'left'); $download_F->ProgressBar(-variable => \$download_percent )->pack(-padx => 5, -side => 'left', -fill => 'x', -expand => +1); $download_F->repeat(25 => sub { $download_amount += int rand 10; if ($download_amount > $file_datum->{size}) { $download_amount = $file_datum->{size}; } $download_percent = $download_amount / $file_datum->{size} * 1 +00; }); } MainLoop;
-- Ken
In reply to Re: Perl Tk Asynchronous Progress Updates
by kcott
in thread Perl Tk Asynchronous Progress Updates
by hermes1908
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |