2

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.

asked Aug 17, 2015 at 13:45
6
  • 1
    I guess you'd have to install a terminal emulator which works on Windows and launch that instead of xterm. Commented Aug 17, 2015 at 13:54
  • 2
    Are you wanting a terminal emulator as described in the title, or a python shell as described in the question? Those are two different things. Commented Aug 17, 2015 at 14:14
  • @BryanOakley im sorry, a python shell. Commented Aug 17, 2015 at 15:00
  • @bleakgadfly any recommendation for embedding to tkinter if possible? but still, thank you very much for your reply! Commented Aug 17, 2015 at 15:04
  • 1
    Have you seen stackoverflow.com/questions/5597836/… ? Commented Aug 17, 2015 at 15:16

1 Answer 1

0

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.

answered Oct 8, 2015 at 2:01
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.