diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 00beecae..b299e63e 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1225,6 +1225,7 @@ class Button(Element): self.ParentForm.LastButtonClicked = self.Key else: self.ParentForm.LastButtonClicked = self.ButtonText + self.ParentForm.TKroot.quit() # kick out of loop if read was called # ------- Button Callback ------- # def ButtonCallBack(self): @@ -2775,6 +2776,18 @@ class Window: self.Show() else: 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: self.TimerCancelled = False self.TKAfterID = self.TKroot.after(timeout, self._TimeoutAlarmCallback) diff --git a/PySimpleGUI27.py b/PySimpleGUI27.py index 1c00b7f2..3c26aed0 100644 --- a/PySimpleGUI27.py +++ b/PySimpleGUI27.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/python from __future__ import print_function from __future__ import division from __future__ import unicode_literals