1
我在編程任務中使用Tkinter,並存在以下問題。 我希望用戶在文本框中輸入值,並且當他/她單擊提交按鈕時,我想根據在文本框中輸入的數字在GUI上添加其他字段。Python,Tkinter,如何更改基於buttonclick的GUI
我試圖將代碼放入函數'displayText()'中,當按下提交按鈕時調用它。然而,我在其中放置的與GUI相關的代碼在窗口加載時加載。
import tkinter
#When user clicks on button
def displayText():
#DO CHANGE IN GUI
root = tkinter.Tk()
button = tkinter.Button(root, text="Submit", command=displayText())
button.pack()
root.mainloop()
感謝您的快速和有益的答案! –