From cb0bbf420fe2d4dabe70820ca3afb3d295bf947c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 18 Nov 2018 13:49:31 -0500 Subject: [PATCH] MORE changes for multiple windows. This time with timeouts. --- PySimpleGUI.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index d3d04e76..0903bcce 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -3033,12 +3033,19 @@ class Window: # else: # print("** REALTIME PROBLEM FOUND **", results) + if self.RootNeedsDestroying: + # print('*** DESTROYING really late***') + self.TKroot.destroy() + # _my_windows.Decrement() + self.LastButtonClicked = None + return None, None + # normal read blocking code.... if timeout != None: self.TimerCancelled = False self.TKAfterID = self.TKroot.after(timeout, self._TimeoutAlarmCallback) self.CurrentlyRunningMainloop = True - # print(f'In main {self.Title}') + # print(f'In main {self.Title} {self.TKroot}') self.TKroot.protocol("WM_DESTROY_WINDOW", self.OnClosingCallback) self.TKroot.protocol("WM_DELETE_WINDOW", self.OnClosingCallback) self.TKroot.mainloop() @@ -3053,9 +3060,11 @@ class Window: # print('** tkafter cancel failed **') self.TimerCancelled = True if self.RootNeedsDestroying: - print('*** DESTROYING LATE ***') + # print('*** DESTROYING LATE ***') self.TKroot.destroy() _my_windows.Decrement() + self.LastButtonClicked = None + return None, None # if form was closed with X if self.LastButtonClicked is None and self.LastKeyboardEvent is None and self.ReturnValues[0] is None: _my_windows.Decrement() @@ -3240,7 +3249,7 @@ class Window: # IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called def OnClosingCallback(self): global _my_windows - print('Got closing callback', self.DisableClose) + # print('Got closing callback', self.DisableClose) if self.DisableClose: return if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!