X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e58eb5674cfac859568c9a4b1030012e1f0eb64..3cebfef17b54f9dacc386f090827b8badb2773d2:/wxPython/src/_core_ex.py diff --git a/wxPython/src/_core_ex.py b/wxPython/src/_core_ex.py index 52edf3c955..0bb3c2e8b4 100644 --- a/wxPython/src/_core_ex.py +++ b/wxPython/src/_core_ex.py @@ -6,6 +6,8 @@ try: except NameError: __builtins__.True = 1==1 __builtins__.False = 1==0 + def bool(value): return not not value + __builtins__.bool = bool @@ -117,7 +119,7 @@ def CallAfter(callable, *args, **kw): class FutureCall: """ - A convenience class for wxTimer, that calls the given callable + A convenience class for wx.Timer, that calls the given callable object once after the given amount of milliseconds, passing any positional or keyword args. The return value of the callable is availbale after it has been run with the GetResult method. @@ -134,6 +136,7 @@ class FutureCall: self.callable = callable self.SetArgs(*args, **kwargs) self.runCount = 0 + self.running = False self.hasRun = False self.result = None self.timer = None @@ -155,6 +158,7 @@ class FutureCall: self.Stop() self.timer = wx.PyTimer(self.Notify) self.timer.Start(self.millis, wx.TIMER_ONE_SHOT) + self.running = True Restart = Start @@ -201,9 +205,12 @@ class FutureCall: """ if self.callable and getattr(self.callable, 'im_self', True): self.runCount += 1 + self.running = False self.result = self.callable(*self.args, **self.kwargs) self.hasRun = True - wx.CallAfter(self.Stop) + if not self.running: + # if it wasn't restarted, then cleanup + wx.CallAfter(self.Stop) #----------------------------------------------------------------------------