我的問題是,我有一個創建一個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