【发布时间】:2017-12-01 04:12:17
【问题描述】:
我试图弄清楚我如何可能从一个 text() 框中获取用户输入,并将其插入到另一个 text() 框中已插入的文本之间,并使其实时自动更新。
简化示例代码:
from Tkinter import *
root = Tk()
hello = Label(text="hello, what's your name?")
hello.grid(sticky=W)
mynameisLabel = Label(text="My name is:")
mynameisLabel.grid(row=1, sticky=W)
responseEntry = Text(width=40, height=1)
responseEntry.grid(row=1, sticky=E)
conclusionText = Text(width=40, height=5)
conclusionText.insert(END, "Ah, so your name is ")
# here is where I intend to somehow .insert() the input from responseEntry
conclusionText.insert(END, "?")
conclusionText.grid(row=2, columnspan=2)
root.mainloop()
【问题讨论】:
标签: python python-2.7 user-interface tkinter tk