我的问题是,我有一个创建一个Tkinter的TOPCLASS对象,然后把现场变成它的一类,我想补充一点,运行的方法(这也是在事件处理程序类)每次按下按钮时,但是当事件被称为它说故障一类的内部Tkinter的事件处理程序
AttributeError: Toplevel instance has no attribute 'updateSearch'
class EditStudentWindow():
def __init__(self):
searchResultList = ['student1', 'student2', 'student3'] # test list
##### window attributes
# create window
self = Tkinter.Toplevel()
#window title
self.title('Edit Students')
##### puts stuff into the window
# text
editStudentInfoLabel = Tkinter.Label(self,text='Select the student from the list below or search for one in the search box provided')
editStudentInfoLabel.grid(row=0, column=0)
# entry box
searchRepositoryEntry = Tkinter.Entry(self)
searchRepositoryEntry.grid(row=1, column=0)
# list box
searchResults = Tkinter.Listbox(self)
searchResults.grid(row=2, column=0)
##### event handler
right here
searchRepositoryEntry.bind('<Key>',command = self.updateSearch)
# search results
for result in searchResultList:
searchResults.insert(Tkinter.END, result)
def updateSearch(self, event):
print('foo')
你觉得`self = Tkinter.Toplevel()`做了什么? – delnan 2011-02-15 17:56:27