[IPython-dev] Putting a kernel inside a GUI (WX or Qt) application so you can run external Qt consoles against it.

Fernando Perez fperez.net@gmail....
Fri Aug 5 02:18:49 CDT 2011


Hi all,

we knew this was in principle possible given the new architecture, but
in working with a colleague today I had to actually implement it, so
I've committed these as examples (they only need 0.11 to run, so you
can just copy these files if you want to play with them, or pull from
master):

https://github.com/ipython/ipython/blob/master/docs/examples/lib/ipkernel_qtapp.py
https://github.com/ipython/ipython/blob/master/docs/examples/lib/ipkernel_wxapp.py

Those two both use the same common machinery:

https://github.com/ipython/ipython/blob/master/docs/examples/lib/internal_ipkernel.py

The idea is that you can have a full IPython kernel embedded in any
GUI app (in this case, shown with either WX or Qt), and the app can
then fire up a Qt console (or you can attach one externally).  The GUI
app is modifying variables (the Count++ button) and dumping the user
namespace to the console via buttons, while the Qt console can plot
variables, run code, etc, that's in the namespace dict.

These examples show that it actually takes very little code, and that
this extra code is fairly generic (I used the same code for both the
Qt and the WX examples).  In a real application it would be structured
slightly differently, but the ideas should be clear from this simple
example.

I hope this is useful, since this is something that I've been asked
*many* times over the years.

Cheers,

f


More information about the IPython-dev mailing list