I was looking for a way to embed python shell inside tkinter, and had no luck finding.
I have searched this up and saw this answer: https://stackoverflow.com/a/30222807/4934971
Which contains:
#!/usr/bin/python
from Tkinter import *
import os
root = Tk()
termf = Frame(root, width = 400, height = 200)
termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()
os.system('xterm -into %d -geometry 80x20 -sb -e python &' % wid)
root.mainloop()
But running it on windows will only return an error because there's no xterm. Though I would like to know of there is any way this can be done in windows.
-
1I guess you'd have to install a terminal emulator which works on Windows and launch that instead of xterm.implmentor– implmentor2015年08月17日 13:54:37 +00:00Commented Aug 17, 2015 at 13:54
-
2Are you wanting a terminal emulator as described in the title, or a python shell as described in the question? Those are two different things.Bryan Oakley– Bryan Oakley2015年08月17日 14:14:53 +00:00Commented Aug 17, 2015 at 14:14
-
@BryanOakley im sorry, a python shell.Ako Cruz– Ako Cruz2015年08月17日 15:00:57 +00:00Commented Aug 17, 2015 at 15:00
-
@bleakgadfly any recommendation for embedding to tkinter if possible? but still, thank you very much for your reply!Ako Cruz– Ako Cruz2015年08月17日 15:04:25 +00:00Commented Aug 17, 2015 at 15:04
-
1Have you seen stackoverflow.com/questions/5597836/… ?Eric Levieil– Eric Levieil2015年08月17日 15:16:13 +00:00Commented Aug 17, 2015 at 15:16
1 Answer 1
Tkinter does not make it easy to create a python shell within a window; however, if you did not save your script as [.pyw], then upon executing the program you will get both a Tkinter window, and a console window.
Any commands dictated in normal python code, such as print, will print to the console. The closest you are going to get is by creating a window that allows actions to happen in the console window.
Comments
Explore related questions
See similar questions with these tags.