简体   繁体   English

Tkinter中的Windows终端仿真器

[英]Terminal Emulator for Windows in tkinter

I was looking for a way to embed python shell inside tkinter, and had no luck finding. 我正在寻找一种将python shell嵌入tkinter的方法,但是没有运气。

I have searched this up and saw this answer: https://stackoverflow.com/a/30222807/4934971 我已经搜索了这个并看到了这个答案: 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 . 但是在Windows上运行它只会返回错误,因为没有xterm Though I would like to know of there is any way this can be done in windows. 尽管我想知道有什么方法可以在Windows中完成。

Tkinter does not make it easy to create a python shell within a window; Tkinter使得在窗口中创建python shell变得不容易。 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. 但是,如果未将脚本另存为[.pyw],则在执行程序时,您将同时获得Tkinter窗口和控制台窗口。

Any commands dictated in normal python code, such as print, will print to the console. 普通python代码中规定的任何命令(例如print)都将打印到控制台。 The closest you are going to get is by creating a window that allows actions to happen in the console window. 您将获得的最接近的结果是创建一个允许在控制台窗口中进行操作的窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM