Merge pull request #601 from MikeTheWatchGuy/Dev-latest
Finally getting window destroyed callbacks!
This commit is contained in:
commit
ab42eee918
|
@ -1252,6 +1252,9 @@ class Button(Element):
|
||||||
# ------- Button Callback ------- #
|
# ------- Button Callback ------- #
|
||||||
def ButtonCallBack(self):
|
def ButtonCallBack(self):
|
||||||
global _my_windows
|
global _my_windows
|
||||||
|
|
||||||
|
# print('Button callback')
|
||||||
|
|
||||||
# print(f'Parent = {self.ParentForm} Position = {self.Position}')
|
# print(f'Parent = {self.ParentForm} Position = {self.Position}')
|
||||||
# Buttons modify targets or return from the form
|
# Buttons modify targets or return from the form
|
||||||
# If modifying target, get the element object at the target and modify its StrVar
|
# If modifying target, get the element object at the target and modify its StrVar
|
||||||
|
@ -2897,6 +2900,8 @@ class Window:
|
||||||
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.protocol("WM_DESTROY_WINDOW", self.OnClosingCallback)
|
||||||
|
self.TKroot.protocol("WM_DELETE_WINDOW", self.OnClosingCallback)
|
||||||
self.TKroot.mainloop()
|
self.TKroot.mainloop()
|
||||||
# print('Out main')
|
# print('Out main')
|
||||||
self.CurrentlyRunningMainloop = False
|
self.CurrentlyRunningMainloop = False
|
||||||
|
@ -3082,8 +3087,12 @@ class Window:
|
||||||
Close = CloseNonBlockingForm
|
Close = CloseNonBlockingForm
|
||||||
|
|
||||||
|
|
||||||
|
# IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called
|
||||||
def OnClosingCallback(self):
|
def OnClosingCallback(self):
|
||||||
# print('Got closing callback')
|
# print('Got closing callback')
|
||||||
|
self.TKroot.quit() # kick the users out of the mainloop
|
||||||
|
self.TKroot.destroy() # kick the users out of the mainloop
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def Disable(self):
|
def Disable(self):
|
||||||
|
@ -4674,10 +4683,11 @@ def StartupTK(my_flex_form):
|
||||||
my_flex_form.TKAfterID = root.after(my_flex_form.Timeout, my_flex_form._TimeoutAlarmCallback)
|
my_flex_form.TKAfterID = root.after(my_flex_form.Timeout, my_flex_form._TimeoutAlarmCallback)
|
||||||
if my_flex_form.NonBlocking:
|
if my_flex_form.NonBlocking:
|
||||||
pass
|
pass
|
||||||
# my_flex_form.TKroot.protocol("WM_DELETE_WINDOW", my_flex_form.OnClosingCallback())
|
|
||||||
else: # it's a blocking form
|
else: # it's a blocking form
|
||||||
# print('..... CALLING MainLoop')
|
# print('..... CALLING MainLoop')
|
||||||
my_flex_form.CurrentlyRunningMainloop = True
|
my_flex_form.CurrentlyRunningMainloop = True
|
||||||
|
my_flex_form.TKroot.protocol("WM_DESTROY_WINDOW", my_flex_form.OnClosingCallback)
|
||||||
|
my_flex_form.TKroot.protocol("WM_DELETE_WINDOW", my_flex_form.OnClosingCallback)
|
||||||
my_flex_form.TKroot.mainloop()
|
my_flex_form.TKroot.mainloop()
|
||||||
my_flex_form.CurrentlyRunningMainloop = False
|
my_flex_form.CurrentlyRunningMainloop = False
|
||||||
my_flex_form.TimerCancelled = True
|
my_flex_form.TimerCancelled = True
|
||||||
|
|
Loading…
Reference in New Issue