5

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.

daf
  • 5,085
  • 4
  • 31
  • 34
  • 1
    Accerciser is a Gtk program with an embedded IPython widget. You might want to have a look at how they do it: https://git.gnome.org/browse/accerciser/tree/plugins/ipython_view.py – Thomas K May 19 '13 at 23:14

1 Answers1

2

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.

jdpipe
  • 232
  • 1
  • 11
  • One little bug I noticed with this: the 'out[1]' text appears (in colour) on stdout, instead of in the GTK-2 window. – jdpipe May 27 '18 at 07:31