Another question about foreach loops and gtk



I have a long-running foreach loop which I want to give feedback through the GUI

ie:

foreach my $keys1 (sort {$a <=> $b} keys %menu_jpegs){
&gd_frame($keys1,$sel_opts_vbox,$menu_file)
}

which runs

sub gd_frame {
my ($keys1,$sel_opts_vbox,$menu_file)= _;
<long function>

my $frame_new=$options{'dir'}.'/dvdjpeg'.$keys1.'.jpeg';
open (FRAME,">",$frame_new);
print FRAME $frame->jpeg;

my $append;
        if ($keys1==1){
        $append=0
        }
        else {
        $append=0
        }
print $keys1,"\n";

&run_cmd(undef,undef,$keys1,undef,'gd',$sel_opts_vbox,undef,$append);

return 1
}

relevant part of run_cmd

else {

my $buffer = $textview->get_buffer;
my $line;
if ($cmd{'gd'} == 1 ){
$line="Frames are being created for DVD Menu\n\nFrame $cmd{'gd'} has
been created\n"
}
else {
$line="Frame $cmd{'gd'} has been created\n";
}
$buffer->insert($buffer->get_end_iter, $line);
$gtkend->set_text($line);


return 1

}

This all runs fine except:


 nothing appears in the GUI until after the loop finishes, rather than
running at each iteration

I have tried
setting an updating label
append/adding v/hboxes
a continue loop
modifying run_cmd and using echo

so far.

I suspect it is something to do with foreach forking processes so
nothing ggoes to Gtk until all processes have finished - any help
appreciated



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