[pygtk] gobject.idle_add and generators
Aravind Vijayakumar
iamfenris at yahoo.com
Fri May 2 01:50:44 WST 2008
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: "skip at pobox.com" <skip at pobox.com>
To: pygtk at daa.com.au
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 - skip at pobox.com - http://www.webfast.com/~skip/
"There's a fine line between a hobby and a mental illness." Ande Rasmussen
_______________________________________________
pygtk mailing list pygtk at daa.com.au
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
More information about the pygtk
mailing list