我想让一个Tkinter窗口能够要求多行输入
(因此用户将添加一行或多行文本)
然后当我们点击按钮,就可以检索到用户输入的值以供进一步使用。在
到目前为止,我有这样的脚本:from Tkinter import *
import ScrolledText
class EntryDemo:
def __init__(self, rootWin):
#Create a entry and button to put in the root window
self.textfield = ScrolledText(rootWin)
#Add some text:
self.textfield.delete(0,END)
self.textfield.insert(0, "Change this text!")
self.textfield.pack()
self.button = Button(rootWin, text="Click Me!", command=self.clicked)
self.button.pack()
def clicked(self):
print("Button was clicked!")
eText = self.textfield.get()
print("The Entry has the following text in it:", eText)
#Create the main root window, instantiate the object, and run the main loop
rootWin = Tk()
#app = EntryDemo( rootWin )
rootWin.mainloop()
但似乎没用,一扇窗户里空无一物。
你能帮帮我吗?在
#########编辑
新代码:
^{pr2}$
抱歉,如果它看起来像是没有努力的一些落选选民(即使我花了一天多的时间),但多行文字输入并不是我们可以称之为充分记录,我们自己学习。在