RE: capturing output from running process crashes gtk2

Ah. I didn't know about that. Thanks for the info and the 
sample code. However, I still have the Gtk2 problem of any 
processing blocking the dialog.

Here is my test code. I want the dialog to be displayed and 
the label to be updated by the while loop. However, as 
listed, the dialog is never displayed. And of course if I 
make it model and add $dialog->run, then the while loop never 
gets run.

What am I doing wrong?

It can not work this way. You need to start the sub process
so that it writes to a pipe, then add the pipe's filehandle
as an IO channel to the Glib/Gtk main loop. All processing
of input from the pipe must be done from the IO channel's
callback (careful here: you must only use non-blocking reads in
this context). Rather advanced stuff, extra credit for 
getting the corner cases (e.g. killing the sub process) right.

The seemingly simple task "display progress output of a
sub process" is a problem for any UI toolkit because of
their inverted program structure of using a main loop and
doing everything from event callbacks. For a ready-made
widget that does this in the context of the perl bindings for Tk

BTW, the g_spawn_* family of Glib functions would be very
helpful here, but AFAICT these have not been wrapped for use
from Perl yet?

Cheers, Roderich

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