如何以编程方式关闭窗口

时间:2014-01-29 10:59:31

标签: python python-3.x tkinter

请告诉我为什么函数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()

0 个答案:

没有答案