[IPython-dev] IPython and Qt?!

Hans Meine hans_meine at gmx.net
Tue May 31 07:22:54 EDT 2005

Hi everybody,

I discovered IPython only recently.  It's a real gem! :-)

We developed our own Qt Python-terminal, but actually I think I could become 
more happy with concentrating on improving IPython instead. (Our GUI is quite 
a mess internally..)

Our current solution actually runs the "internal" python interpreter in a 
separate process; now I am curious whether we can reach the same goal with a 
separate thread, too.  I patch IPython/Shell.py to run a QApplication in a 
separate thread, and my first experiments were quite successful.

Would you like to have a look at it and tell me whether there is a reason that 
Qt was not yet supported?

One possible problem that I see is the following, quoted from

"In Qt, one thread is always the GUI or event thread. This is the thread that 
creates a QApplication object and calls QApplication::exec(). This is also 
the initial thread that calls main() at program start. This thread is the 
only thread that is allowed to perform GUI operations, including generating 
and receiving events from the window system. Qt does not support creating 
QApplication and running the event loop (with QApplication::exec()) in a 
secondary thread. You must create the QApplication object and call 
QApplication::exec() from the main() function in your program.

"Threads that wish to display data in a widget cannot modify the widget 
directly, so they must post an event to the widget using 
QApplication::postEvent(). The event will be delivered later on by the GUI 

Now I wonder whether the commands I type in the ipython shell are executed in 
the right thread (the one running QApplication::exec(), resp. .exec_loop() in 
python)?  I did not yet run into problems, but of course there could be 
timing problems that I have later?

Ciao, /  /
    /  / ANS

More information about the IPython-dev mailing list