I'm writing a gui front end to a command line text indexing tool and am having trouble getting a status window to open. I would like to open a second main window before a pipe is opened to run the index command. The second window does open, but, only after the pipe has closed and the sub has completed, returning the app back to the MainLoop. The piped process can take 10 to 15 minutes and I need to pop the second window to let the user know the app is still do something.
This is a concise version of the code,
Is it the case that the pack requests in the sub all happen as the sub closes? Is it the return to the MainLoop that triggers the refresh on the display? Any ideas would be appreciated.
Thanks,
keep the rudder amid ship and beware the odd typo
This is a concise version of the code,
Code:
#!/usr/local/bin/perl -w
use Tk;
# Create main interface window
my $mw1 = MainWindow->new;
$mw1->configure(-title=>"Isite Admin");
$mw1->geometry('750x600+50+0');
# Create new frame for mode buttons
my $fr1 = $mw1->Frame(-relief=>'groove',
-borderwidth=>1)
->pack(-side=>'top', -fill=>'both');
# create menuButtons
my $IindexMenu = $fr1->Menubutton(-text=>"DB Admin.",
-tearoff=>0,
-relief=>'raised',
-menuitems=>[
['command'=>"Erase Index", -command=> [\&confirm, 'Erase']],
['command'=>"Create an Index", -command=> \&createIndex ],
['command'=>"Edit File List", -command=> \&findList ]])
->pack(-side=>'left');
MainLoop;
--------------------------------
sub createIndex
{
&clearFrames;
# get some input and call sub buildIndex on button press
# frame7 has been created and the button works to call buildIndex.
$frame7->Button(-text=>'Create Index',
-command=> \&buildIndex)
->pack(-side=>'left');
}
--------------------------------
# The PROBLEM SUB IS HERE
sub buildIndex
{
$message = "Building $dbName on $dbPath";
# I want this window to pop open before the CMD below runs
my $mw2 = MainWindow->new;
$mw2->configure(-title=>"Isite Admin", -background=>'white');
$mw2->geometry('400x50+140+20');
my $mw2fr1 = $mw2->Frame(-relief=>'groove',
-background=>'white',
-borderwidth=>1)
->pack(-expand=>'1', -side=>'top', -fill=>'both');
$mw2fr1->Label(-text=>"Building $newDBName on path $dbPath.")
->pack(-side=>'top');
open(CMD,"$cmd2 |") or die "Failed to open CMD pipe";
while (defined($line = <CMD>)) { $text->insert("end",$line);}
close CMD;
$message = "Index Build Complete";
}
Is it the case that the pack requests in the sub all happen as the sub closes? Is it the return to the MainLoop that triggers the refresh on the display? Any ideas would be appreciated.
Thanks,
keep the rudder amid ship and beware the odd typo