2016-08-12 30 views
0

如何關閉整個程序,一旦用戶在消息框中點擊確定tkinter,消息框關閉程序點擊「確定」

這裏是包含按鈕和命令腳本的一部分:

class Application(tk.Tk): 
    def create_options(self): 

     tk.Button(self, 
        text = "Begin search", command=self.pop_up1 
       ).place(x=465, y=285) 

    def pop_up1(self): 
     """shows submitted box""" 
     tkMessageBox.showinfo(title="Finished", message="Query Submitted") 

回答

1

這取決於你的退出的意思,整個程序,您可以通過使用 self.root.destroy() 但根據關閉窗口您關閉窗口的實現可能不會結束您的程序,但通常這是關閉tkinter應用程序的方式。只需將其添加到按鈕事件的末尾即可。

+0

謝謝!我使用了 self.destroy() 並且做了訣竅。 – TheHoff

+0

歡迎你,祝你的項目:) – D3181

+1

@TheHoff記得標記這個答案爲接受點擊關閉在左邊的複選標記。 –