Steven Howe ha scritto:

Yes, checkout gtk.input_add_full.
http://www.moeraki.com/pygtktutorial/pygtk2tutorial/ch-TimeoutsIOAndIdleFunctions.html

The tutorial needs some updating. It describes only three args, but it
takes more. Everyone after the third are passed to the third arg, which
should be a function call.

example: gtk.input_add_full( self.dsk.progressFile, /* the file to monitor */ gtk.gdk.INPUT_READ, /* flag to input_add_full */
self.dsk.readProgress, /* route to call when there is data in
self.dsk.progressFile */
self.updategui ) /* additional parms to pass */


inside dsk.readProgress, (another class)
def readProgress( self, fx, mode, updateFunction=None )

Here's were the tutoral is screwy.

gtk.input_add_full calls readProgress (arg[2]) and passes it:
(arg[0],arg[1], arg[3], ....)

So given:
        gtk.input_add_full( arg0,arg1,arg2,arg3,...argN)
when there is data gtk.input_add_full will call arg2 like:
        arg2(arg0,arg1,arg3...argN)

arg2, your routine should read and process the data stream. It must
return TRUE if you want gtk.input_add_full, to continue to watch for new
data. When you are done close your file stream and return FALSE,

----------------
My function, readProgress, reads the data, updates class variables,
calls updategui, and returns TRUE (until the end of file is reached).
updategui looks like:

----------------

def updategui( self ):
while gtk.events_pending() :
gtk.mainiteration()
return


This function is optional. If your readProgress routine is long, you'll
want to do it.

on the gui side of the program, I set timeouts to read the class dsk
variables, and update a progress bar.

Hope that's enough sample code to guide you.



Steven Howe <[EMAIL PROTECTED]>

On Mon, 2004-04-26 at 23:58, Dario M�ndez wrote:


Greetings everyone, I've just began PyGTK developing today and I started to get my GTKmm kernel compilation utility "ported" to PyGTK.

In order to display the make ouput I used a particular Glib method (spawn_async_with_pipes).

I've tryed looking around, but I didn't find any equivalent, so I hooked up the old popen(), wich, of course, freezes the window during the make process.

Does anybody know a way to display the popen output while the process is running?
Thanks in advance
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


There's something I can't understand, do I have to assign

self.dsk.progressFile = popen(...)

before doing the gtk.input_add_full() thing?

Thanks



--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Sponsor:

Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=&d=28-4
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to