0
我的问题是,我第一次运行该程序时,它的工作正常,但是当我修改我的查询并点击“Go!”时按钮,没有任何反应。我希望它做了同样的事情,以便当我输入一个新的查询时,它重新加载了与最后一个查询相对应的信息的文本框。Tkinter只能工作一次
from Tkinter import *
root = Tk()
#Here's an entry box
search_label = Label(root, text="Enter search here:")
search_entry = Entry(root)
search_label.pack()
search_entry.pack()
#This happens when you hit "go!"
def go():
#It opens a text box in which the answer required is written.
query=search_entry.get()
bibliography = Text(root)
bibliography.insert(INSERT, answer_box(query))
bibliography.pack()
#This is the "go!" button
go_button = Button(root, text="Go!", width=10, command=go)
go_button.pack()
root.mainloop()
有些想法?
'answer_box' is undefined - 我认为这不是您的完整代码?另外,当我用'query'替换'answer_box(query)'时,我可以运行它,但重复使用'go_button'会导致新的文本框被添加到下面的新查询文本中。你确定没有发生?它会发生在你的屏幕上吗?另外,你是否打算在每次点击'go_button'时创建一个新的文本框? – Brionius