[IPython-User] busy python prompt blocking Qt4 timers with ipy 0.11?

Václav Šmilauer ipython@doxos...
Wed Jul 13 09:03:42 CDT 2011


I have a python program embedding ipython as its interactive shell, 
which optionally opens UI written in PyQt4 and c++/Qt4. The UI 
instantiates an class called "OpenGLManager" which receives every 50ms 
timer event triggering OpenGL repaint.

It is not clear to me (despite reading docs) how to integrate this with 
ipython 0.11. I proceed as follows now:

1. qapp=IPython.lib.guisupport.get_app_qt4() # used to be 
QtGui.QApplication() with 0.10
2. IPython.embed()  # was IPShellEmbed(...)()

Does IPython.embed() start the event loop automatically? If start the 
event loop explicitly via IPython.lib.guisupport.start_event_loop_qt4(), 
the call does not return, and I will never get to call IPython.embed().

Now I am in the embedded shell, the UI works and OpenGL is repainted 
every 50ms. Then I run the following loop:

   for i in range(1000): time.sleep(0.1)

and I observe that the UI is blocked during the whole loop (although 
time.sleep should yield control to another threads in python), just the 
same as with 0.10. Can something be done about it? Can I run PyQt4 UI 
along with ipython in terminal independently? (I tried, for instance, to 
run PyQt4 in separate thread, but it insists on being run in the main 
thread). Would the kernel/frontend way work better in this case? Can I 
get some pointers?

Cheers, Vaclav

More information about the IPython-User mailing list