You should start with an analysis of what you expect:
- input from user: what do you want, how you want to process it? (is this really shell input?)
- feed back: what do you want to display, how is it produced? (direct shell output?)
xterm is just a graphic interface around a shell. That means that is captures keyboard input coming to its window, submit it to is shell, and in turn display its shell stdout and stderr to the window, with respect to formatting code (not for from vt220 terminal + ANSI color codes). It is uncommon to use xterm in a GUI.
The shell can be any command line program that processes standard input and uses standard output and standard error streams. It is commonly /bin/sh
or bin/bash
but could be any program.
If you really want to do that, you could start xterm in a subprocess, with a special shell that passes all input lines to your main program for example through a Unix domain socket, and in turn echoes back what your main program sends to it.
More commonly, GUIs use an text widget to get input from the user and another or the same widget to display feedback. Until you have analyzed things at that level and designed a global architecture please do not think too much about subprocess module syntax.