[IPython-user] gtk.main_iteration() blocks ipython

Pieter Cristiaan de Groot p.c.degroot@tudelft...
Sat Apr 12 04:55:47 CDT 2008

Dear all,

I think I solved my problem of the blocking gtk.main_iteration()
I changed two things:

1) instead of running gtk.main_iteration() inside ipython, I emit a 
signal (with gobject), that is picked up by the gui. The gui then runs a 
callback function. HOWEVER: this alone did not solve the problem.

2) instead of running just gtk.main_iteration(False), I run:
        while gtk.events_pending():

The 'entering' and 'leaving' of the threads seemed to be the crucial 
step. Probaly you can leave out point 1) altogether, but I think it is 
more elegant like this.

Hope it helps somebody,

Pieter Cristiaan de Groot wrote:
> using gtk.main_iteration(block=False) has a different behaviour the 
> second time you use it ( so after the time-out warning and switching 
> to non-threaded mode). Ipython is now completely usable, but the gui 
> not anymore. It is also not predictable. Sometimes when clicking the 
> buttons (without any visual feedback by the way) will give you the 
> specified action after you run 'gtk.main_iteration(block=False), but 
> sometimes it does not.
> does this give a clue?
> Is this a bug that I need to report somewhere?
> Ville M. Vainio wrote:
>> On Wed, Apr 9, 2008 at 10:48 AM, Pieter Cristiaan de Groot
>> <p.c.degroot@tudelft.nl> wrote:
>>>  At this point the gui is not responding anymore, but the ipython shell
>>>  usable. When I run the gtk.main_iteration() a second time the ipython
>>>  shell blocks (just as before), but the gui is completely usable. Which
>>>  is probably what you expect in non-threaded mode.
>> This seems to suggest that gtk.main_iteration() does return at all
>> (which is weird, considering the API docs). Did you try with
>> gt.main_iteration(block = False)?

More information about the IPython-user mailing list