Well, given the practicalities involved with this project, I've made an executive decision(!)...
I'll use the idea that has been suggested of updating a progress bar on a pop-up window... and just get it to run a 'resonable time' (which I'll determine by a few test runs), after which I'll check if the file I'm expecting to see has been created. If it's not there or some other error occurs, I'll deal with that AFTER the 'Working' pop-up has gone.
As this program I'm building is just a 'make-do' thing until some other people fix-up the problems we've reported in their software, what I've described will probably be sufficient; it doesn't have to be 'perfect'(!)... and it certainly doesn't justify all the development/debugging required for IPC/process communications.
Many thanks for all your assistance, folks... I appreciate it a lot.
BTW... The final sample code I'll further massage follows:
use strict;
use Tk;
use Tk::ProgressBar; # WHY is this required, given the prior line?
# If it's not included I get warnings!?
my $MAXTIME = 10;
my $mw = MainWindow->new; # Main window
my $top = $mw->Frame(
-background => '#239867',
-borderwidth => 2,
)->pack(-fill => 'both');
my $lbltxt = $top->Label(
-text => 'Just some text',
-background => 'white',
)->pack(-side => 'right', -padx => 10);
my $GoBtn = $top->Button(
-text => ' Pop It! ',
-command => \&AddItemNew
)->pack(-side => 'left', -padx => 10, -pady => 5);
my $DoneBtn = $top->Button(
-text => ' Exit ',
-command => \&Cleanup
)->pack(-side => 'right', -padx => 10, -pady => 5);
$mw->focus; # Ensure we're talking to the main window
MainLoop; # Run the program, watching for events
# ----
sub Cleanup {
$mw->destroy;
}
# ----
sub AddItem {
my $tp = $mw->Toplevel(
-title => ' AddItem'
); # ->pack(-fill => 'both');
my $tpfrm = $tp->Frame(
-background => '#22cc00',
)->pack(-side => 'top', -fill => 'x');
my $tplbl = $tpfrm->Label(
-text => 'Working...',
-background => 'white',
-foreground => 'black'
)->pack(-side => 'top', -padx => 10);
my $tpbtn = $tpfrm->Button(
-text => 'Close',
-command => [$tp => 'destroy'],
)->pack(-side => 'top', -padx => 10, -pady => 5);
}
# ----
sub AddItemNew {
my $tp = $mw->Toplevel(
-title => ' AddItem'
); # ->pack(-fill => 'both');
my $tpfrm = $tp->Frame(
-background => '#22cc00',
)->pack(-side => 'top', -fill => 'x');
my $tplbl = $tpfrm->Label(
-text => 'Working...',
-background => 'white',
-foreground => 'black'
)->pack(-side => 'top', -padx => 10);
$GoBtn->configure(-state => "disabled");
my $progress = $tpfrm->ProgressBar(
-width => 20,
-length => 100,
-anchor => 'w',
-state => 'disabled',
-value => 0,
-from => 0,
-to => $MAXTIME-1,
-blocks => 1,
-colors => [0, 'blue']
)->pack();
for (0..$MAXTIME-1) {
$progress->value($_);
$progress->update();
sleep 1;
}
$tp->withdraw;
$GoBtn->configure(-state => "normal");
}
|