I think you'll have to call it like this:

iter = g()
gobject.idle_add(iter.next)

And yes, to terminate the idle execution, you would yield False.

-Aravind

----- Original Message ----
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, May 1, 2008 8:05:16 AM
Subject: [pygtk] gobject.idle_add and generators


Sorry, kind of new to the idea of using simple generators in place of
regular functions, but I think I have the classic "need to save intermediate
state" case which would make it worthwhile.  The current function-based
approach I'm using is pretty cumbersome.  Suppose g is a simple generator:

    def g():
        while True:
            do_something_useful()
            yield True

Does it make sense to call it like this?

    gobject.idle_add(g)

If I want to terminate the idle execution I suppose I'd have to arrange to
yield False instead of True, just as with a regular function, yes?

Thx,

-- 
Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/
"There's a fine line between a hobby and a mental illness."  Ande Rasmussen
_______________________________________________
pygtk mailing list  [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
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