Split apart timeout=(key,time) intp 2 parms timeout, key

This commit is contained in:
MikeTheWatchGuy 2018-10-18 14:33:57 -04:00
parent 01a2806eef
commit aa40a73266
1 changed files with 9 additions and 7 deletions

View File

@ -2475,7 +2475,8 @@ class Window:
self.ForceTopLevel = force_toplevel self.ForceTopLevel = force_toplevel
self.Resizable = resizable self.Resizable = resizable
self._AlphaChannel = alpha_channel self._AlphaChannel = alpha_channel
self.Timeout = (None, None) self.Timeout = None
self.TimeoutKey = '_timeout_'
self.TimerCancelled = False self.TimerCancelled = False
# ------------------------- Add ONE Row to Form ------------------------- # # ------------------------- Add ONE Row to Form ------------------------- #
@ -2579,13 +2580,14 @@ class Window:
# modify the Results table in the parent FlexForm object # modify the Results table in the parent FlexForm object
if self.TimerCancelled: if self.TimerCancelled:
return return
self.LastButtonClicked = self.Timeout[0] self.LastButtonClicked = self.TimeoutKey
self.FormRemainedOpen = True self.FormRemainedOpen = True
self.TKroot.quit() # kick the users out of the mainloop self.TKroot.quit() # kick the users out of the mainloop
def Read(self, timeout=(None, None)): def Read(self, timeout=None, timeout_key='_timeout_'):
self.Timeout = timeout self.Timeout = timeout
self.TimeoutKey = timeout_key
self.NonBlocking = False self.NonBlocking = False
if self.TKrootDestroyed: if self.TKrootDestroyed:
return None, None return None, None
@ -2593,9 +2595,9 @@ class Window:
self.Show() self.Show()
else: else:
InitializeResults(self) InitializeResults(self)
if timeout != (None, None): if timeout != None:
self.TimerCancelled = False self.TimerCancelled = False
self.TKAfterID = self.TKroot.after(self.Timeout[1], self._TimeoutAlarmCallback) self.TKAfterID = self.TKroot.after(timeout, self._TimeoutAlarmCallback)
self.TKroot.mainloop() self.TKroot.mainloop()
self.TimerCancelled = True self.TimerCancelled = True
if self.RootNeedsDestroying: if self.RootNeedsDestroying:
@ -4097,8 +4099,8 @@ def StartupTK(my_flex_form):
duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration
my_flex_form.TKAfterID = root.after(duration * 1000, my_flex_form._AutoCloseAlarmCallback) my_flex_form.TKAfterID = root.after(duration * 1000, my_flex_form._AutoCloseAlarmCallback)
if my_flex_form.Timeout != (None, None): if my_flex_form.Timeout != None:
my_flex_form.TKAfterID = root.after(my_flex_form.Timeout[1], 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()) # my_flex_form.TKroot.protocol("WM_DELETE_WINDOW", my_flex_form.OnClosingCallback())