[Tutor] open extra xterm?

Michael Janssen Janssen@rz.uni-frankfurt.de
Sun Jan 5 08:10:02 2003


On Sat, 4 Jan 2003, Scott wrote:

> I'm working on a python program that will defintely need a GUI.  I'll
> probably do it in Tkinter.  But I want to get the guts of my program
> working before I start learning Tkinter.
>
> So I need at least two windows.  How do I open a second xterm for
> output, while I use my main one as a readline terminal?  I'm assuming
> pipes or something like that, but could someone show me a small example
> of spawning an xterm and writing to it.  Thank you.

Hello Scott,

I can only give you some hints:

writing to another terminal is easy:

>>> fo = open("/dev/pts/4","w")
>>> fo.write("hello")
>>> fo.flush()

this will print to terminal pts/4. Use ps to identify the current
terminals:
ps -a : gives you processes run by the terminal shells. You can use "sleep
10" on your second xterm to identify it.
ps -Nx : gives you every terminal related process (including the shells)

The problem is: you need to identify the pts and (more important) you need
to start the xterm from outside the script.

When you want to work around this, *probably* os.fork() os.forkpty() and
the pty module helps you. Or you get os.system() or os.popen2() to work
(they can start a xterm but this will run under the pts-device of the
python interpreter. The popen2 fileobjects doesn't work [for me]).


Would you drop me a line when you find a solution?

Michael
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>