1
我創建了一個Python因子程序,我用tkinter將它設置爲將輸入到輸入框的數字打印到Python shell中,但是我怎麼而是將其打印到單獨的文本框中?這裏是我的代碼:從Tkinter的進口*Python GUI - 打印到文本框而不是Shell Py 3.3
def factorial(n):
first = True
for number in range(1, n+1):
if first:
answer = number
first = False
else:
answer = answer * number
return answer
def callback():
n = int(e.get())
print(factorial(n))
window = Tk()
e = Entry(window)
e.pack()
t = Text()
t.pack()
e.focus_set()
b = Button(window, text="get", width=10, command=callback)
b.pack()
mainloop()