我想知道是否有可能(如果是这样,如何)Python Shell在tkinter我所做的窗口内输出和输入.我在谷歌搜索,但我似乎找不到任何东西.如果可能的话,是否有初学者可以理解的简短版本.(我试过的所有网站都无法理解.)
这是我的代码:
from tkinter import *
def Exit():
print()
def newClassResults():
#assigns variable to an input so it can be reffered to later
amount = int(input("How many people would you like to add? "))
#starts for loop
for counter in range(amount):
#assigns inputto a variable called 'newName'
newName = input("\nEnter the new student's name: ")
#assigns input to a variable called 'newScore'
newScore = int(input("Enter the new student's score: "))
#adds new results to the …Run Code Online (Sandbox Code Playgroud) 可以编写一个简单的python脚本来嵌入xterm到tk框架中:
from Tkinter import *
import subprocess
root = Tk()
termf = Frame(root, height=800, width=1000)
termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()
Run Code Online (Sandbox Code Playgroud)
窗口建立后
proc = subprocess.Popen('xterm -into %d -sb ' % wid,shell=True)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)