1

So i'm working with python and tkinter and i'm trying to embed a console into a GUI and I've tried to find the solution on other pages and across other website but I still cant find the answer. (code from How to embed a terminal in a Tkinter application?)

Here is the code that I am working with:

from tkinter import *
import os

root = 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()

And here is the error i'm getting in console:

Process started >>>
'xterm' is not recognized as an internal or external command,
operable program or batch file.
<<< Process finished. (Exit code 0)

I'm assuming that xterm is short for x terminal or something but please correct me if i'm wrong.

Also sorry if the format of the console is a little different as I am using a console plugin in Notepad ++ but from my understanding it should look exactly like it does in the Python IDLE.

(As an afterthought I think I should add that a window opens but its blank and it gives me the error in console.)

Community
  • 1
  • 1
IronReign
  • 97
  • 2
  • 3
  • 7
  • You need xterm program, on your path. First try ` which xterm` in your prompt - that would tell where it is. It can be that your python code goes with a bit different env. You can change that `xtem -into.... ` with `which xterm`, or even `set` - to see how environment looks in that particular case. – Michał Zaborowski May 01 '16 at 09:12
  • Which operating system are you running on? `xterm` is common on Linux but might not exist elsewhere. – cdarke May 01 '16 at 09:27
  • If you are running on Microsoft's Windows then the next question is if you want the console to run in the same process or a different one. If the same then you will need to call an API to create a console, if different (which is what `xterm` does on Linux) then just call `cmd.exe`. But don't use `os.system`, since that will run *another* `cmd.exe` (that's that blank window which opens). Use the `subprocess` module from the standard library. – cdarke May 01 '16 at 09:35
  • not sure how to follow these pieces of advice and running into same problem (on WINDOWS) – makmak Nov 25 '22 at 20:32

0 Answers0