updating gui while running a subroutine



Hi folks, looking for a little assistance, and I'm sure it is just something simple that I can do to fix this. Using the information from an earlier thread I have it so when my GUI is running an external program a text-view that I have for monitoring progress updates. I've done this as Muppet recommended using the following:

<code>
my $main_loop = Glib::MainLoop -> new();
my $execute_command = "blastall -p $algorithm -a $num_processors -b 5 -v 5 -z  20000000      -F ''"m S"' . " -i $file -d $database -o $out";
$pid = open CHILD, "$execute_command |" or die "Can't fork BLAST: $!";
                   
printToBuffer("BLAST executing with PID: $pid\n");
                   
my $data = "" blastall -p $algorithm -a $num_processors -b 5 -v 5 -z 20000000 -F " .
                  '"m S"' . " -i $file -d $database -o $out\n\n";
printToBuffer($data);  
                   
Glib::IO -> add_watch(fileno CHILD, ['hup'],
                                 sub {
                                    $main_loop->quit;
                                    FALSE;
                                 }
                                );
                   
$main_loop -> run();
                   
close CHILD or warn "$pid died with exit status ". ($? >> 8)."\n";
if(($? >> 8) != 0){
           printToBuffer("Exiting BLAST subroutine...\n");
                       
            my $exit_message = "$pid died with exit status ". ($? >> 8)."\n";
            printToBuffer($exit_message);
                       
            return 1;
}
</code>

I am now trying to do something similar forking a subroutine from within my own program but am having difficulty getting it to work. The above is embedded in a looping process and works perfectly. Once I exit out of that looping process and after doing some more straightforward processing I want to call a series of subroutines (I call one subroutine, which after it finishes calls another subroutine from within itself and the program then finishes)

I want to call this first subroutine in a similar manner to above so that the GUI will still update with progress messages as I do in the above example.

Is there something special I need to do with the piped open/fork to have it work for a subroutine within the same program code?

Thanks.

Dan Gaston


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]