tags:

views:

226

answers:

1

Is there a way to schedule the execution of a callable until the glib main loop is entered?

Alternatively, is there a signal I can subscribe to that will indicate that the main loop is entered?

+1  A: 

You can use gobject.idle_add which will schedule a callable to be executed when the main loop is idle. gobject.timeout_add is an alternative which uses a timer.

Mind that the callable will be called again and again, unless is returns False (or anything that resolves to False, like None).

AndiDog
The trick with "timeout_add, return False" serves as a good "one-shot callable", exactly what I needed. Thanks!
jldupont
Returning no value at all would work, too, because Python functions automatically return `None`. But better do it explicitly...
AndiDog