MORE changes for multiple windows. This time with timeouts.

This commit is contained in:
MikeTheWatchGuy 2018-11-18 13:49:31 -05:00
parent a5244553a6
commit cb0bbf420f
1 changed files with 12 additions and 3 deletions

View File

@ -3033,12 +3033,19 @@ class Window:
# else: # else:
# print("** REALTIME PROBLEM FOUND **", results) # 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.... # normal read blocking code....
if timeout != None: if timeout != None:
self.TimerCancelled = False self.TimerCancelled = False
self.TKAfterID = self.TKroot.after(timeout, self._TimeoutAlarmCallback) self.TKAfterID = self.TKroot.after(timeout, self._TimeoutAlarmCallback)
self.CurrentlyRunningMainloop = True 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_DESTROY_WINDOW", self.OnClosingCallback)
self.TKroot.protocol("WM_DELETE_WINDOW", self.OnClosingCallback) self.TKroot.protocol("WM_DELETE_WINDOW", self.OnClosingCallback)
self.TKroot.mainloop() self.TKroot.mainloop()
@ -3053,9 +3060,11 @@ class Window:
# print('** tkafter cancel failed **') # print('** tkafter cancel failed **')
self.TimerCancelled = True self.TimerCancelled = True
if self.RootNeedsDestroying: if self.RootNeedsDestroying:
print('*** DESTROYING LATE ***') # print('*** DESTROYING LATE ***')
self.TKroot.destroy() self.TKroot.destroy()
_my_windows.Decrement() _my_windows.Decrement()
self.LastButtonClicked = None
return None, None
# if form was closed with X # if form was closed with X
if self.LastButtonClicked is None and self.LastKeyboardEvent is None and self.ReturnValues[0] is None: if self.LastButtonClicked is None and self.LastKeyboardEvent is None and self.ReturnValues[0] is None:
_my_windows.Decrement() _my_windows.Decrement()
@ -3240,7 +3249,7 @@ class Window:
# IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called # IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called
def OnClosingCallback(self): def OnClosingCallback(self):
global _my_windows global _my_windows
print('Got closing callback', self.DisableClose) # print('Got closing callback', self.DisableClose)
if self.DisableClose: if self.DisableClose:
return return
if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit! if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!