r/IPython • • Nov 08 '18

Attach virtual terminal emulator to IPython

Hi,

I am wondering if it is possible to make IPython interact with a virtual terminal (PTY) instead of stdin/stdout/stderr.

I am trying to get an IPython shell to run inside a pygtk widget. Right now I am using the Gtk.VTE widget. When creating it, I fork my process and attach the childs PTY to the Gtk.VTE widget and in the child process I run IPython.embed. Unfortunately since I am spawning a new process I cannot access data that is changed after the fork. I would like to change the forked process into a thread, but threads do not have their own terminal, so this solution will not work.

Is it possible to tell IPython to use the Gtk.VTE PTY instead of the actual terminal that started the process?

I found this widget doing exactly what I want, but it is not compatible with IPython 7.

2 Upvotes

20 comments sorted by

View all comments

Show parent comment

1

u/bent93 Nov 08 '18

This is just a small part of my project, and I want to write my project in GTK, not Qt. It may be possible to integrate the Qt window in GTK, but I would have to launch a new process for that and that process would not have access to stuff I need in the main process.
Basically I want the terminal-window to have access to some data-structures that are changable from other places as well. Therefore spawning a new process is not what I want. If it were, I could just use Gtk.VTE to spawn the new process. I tried that initialiy to get a feel for Gtk.VTE and it works very well, but is not suited for my needs.