Merge pull request #552 from MikeTheWatchGuy/Dev-latest
Improved RealtimeButton code! Does not require non-blocking reads
This commit is contained in:
commit
9714229ae9
|
@ -1225,6 +1225,7 @@ class Button(Element):
|
||||||
self.ParentForm.LastButtonClicked = self.Key
|
self.ParentForm.LastButtonClicked = self.Key
|
||||||
else:
|
else:
|
||||||
self.ParentForm.LastButtonClicked = self.ButtonText
|
self.ParentForm.LastButtonClicked = self.ButtonText
|
||||||
|
self.ParentForm.TKroot.quit() # kick out of loop if read was called
|
||||||
|
|
||||||
# ------- Button Callback ------- #
|
# ------- Button Callback ------- #
|
||||||
def ButtonCallBack(self):
|
def ButtonCallBack(self):
|
||||||
|
@ -2775,6 +2776,18 @@ class Window:
|
||||||
self.Show()
|
self.Show()
|
||||||
else:
|
else:
|
||||||
InitializeResults(self)
|
InitializeResults(self)
|
||||||
|
# if the last button clicked was realtime, emulate a read non-blocking
|
||||||
|
# the idea is to quickly return realtime buttons without any blocks until released
|
||||||
|
if self.LastButtonClickedWasRealtime:
|
||||||
|
try:
|
||||||
|
rc = self.TKroot.update()
|
||||||
|
except:
|
||||||
|
self.TKrootDestroyed = True
|
||||||
|
_my_windows.Decrement()
|
||||||
|
results = BuildResults(self, False, self)
|
||||||
|
if results[0] != None and results[0] != timeout_key:
|
||||||
|
return results
|
||||||
|
# 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)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
Loading…
Reference in New Issue