请告诉我为什么函数quit()
没有关闭程序。我使用python3.3
import tkinter
import tkinter.messagebox
class Quitter(tkinter.Frame):
def __init__(self, parent=None):
tkinter.Frame.__init__(self, parent)
self.pack()
widget = tkinter.Button(self, text='Quit', command=self.quit)
widget.pack(side='left', expand='yes', fill=tkinter.BOTH)
def quit(self):
ans = tkinter.messagebox.askokcancel('Verify exit', "Really quit?")
if ans:
print('exitt')
tkinter.Frame.quit(self)
else:
print('noexitt')
if __name__ == '__main__': Quitter().mainloop()