From f0e7ed829a9d77c55ebfc5a3ee7a5ea57c09d91d Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Mon, 8 May 2017 00:01:59 +0300 Subject: [PATCH] Properly terminate program on GUI window close while tests are running --- blockcheck.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/blockcheck.py b/blockcheck.py index bb481cf..bc98a2a 100755 --- a/blockcheck.py +++ b/blockcheck.py @@ -149,6 +149,10 @@ try: pass self.after(100, self.update_me) + def tk_terminate(): + root.destroy() + raise SystemExit + except ImportError: tkusable = False @@ -983,10 +987,14 @@ if __name__ == "__main__": if tkusable: root = tk.Tk() root.title("BlockCheck") + root.protocol("WM_DELETE_WINDOW", tk_terminate) text = ThreadSafeConsole(root) text.pack(expand=1, fill='both') threading.Thread(target=main).start() - root.mainloop() + try: + root.mainloop() + except SystemExit: + os._exit(0) else: try: main()