Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding an IPython shell in a Gtk+ program

I'd like to embed an IPython shell inside a graphical Gtk+ program. The traditional IPython embedding API is geared towards console usage.

It should be possible to export program variables to the shell so that the user can use the shell to interact with the rest of the program.

like image 735
daf Avatar asked Nov 02 '22 21:11

daf


1 Answers

Some work was done in the ns-3 project to update the embedding of IPython into GTK-2, from around 2014. That code looks like it might be compatible with IPython 4.x but not with 5.x. As of IPython 5.x, everything seems to have changed: see the new documentation. But there is also a rough patch that makes this work in IPython 5, at least in a basic way.

From the above, a patched and working version of ipython_view.py is at:

http://code.ascend4.org/ascend/trunk/pygtk/ipython_view.py?view=markup

Test it using:

python python-iview.py

It seems to work OK on both Ubuntu 17.10 (IPython 5.1.0) and Ubuntu 16.04 (IPython 2.4.1). The color prompt is not enabled (yet) with the IPython 5.x version.

like image 78
jdpipe Avatar answered Nov 15 '22 06:11

jdpipe