How to embed a terminal in a Tkinter application? How to embed a terminal in a Tkinter application? tkinter tkinter

How to embed a terminal in a Tkinter application?


I am happy to say that it is in fact possible to do it, and you can do it with just a few lines of code (I don't know if it is so easy with other toolkits):

from Tkinter import *import osroot = Tk()termf = Frame(root, height=400, width=500)termf.pack(fill=BOTH, expand=YES)wid = termf.winfo_id()os.system('xterm -into %d -geometry 40x20 -sb &' % wid)root.mainloop()

The problem before was to use the wrong function for wid.


Alessandro already reported five hours before what he regards as an adequate model. For those who come across this item during future searches, I'll record a few more background facts I know:

It was fortunate that Bryan was here to draw attention to the differences between window_id() and winfo_id(), and to counter the errors others made in writing about various toolkits.

It's interesting to me how stackoverflow compares to more specialized channels. In this case, the Tkinter mailing list http://mail.python.org/pipermail/tkinter-discuss/2011-September/002968.html swiftly and accurately responded to the question.

Tkinter would be an improvement on at least some of the moon-rocket software.