Skip to content

Commit a486adc

Browse files
committed
add timers to runloop so they don't block on UI drags
1 parent df340c2 commit a486adc

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

plotdevice/gui/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ def bundle_path(subpath=None, rsrc=None, fmwk=None):
1111
return join(bundle, subpath)
1212
return bundle
1313

14-
from Foundation import NSTimer
14+
from Foundation import NSTimer, NSRunLoop, NSRunLoopCommonModes
1515
def set_timeout(target, sel, delay, info=None, repeat=False):
16-
return NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(delay, target, sel, info, repeat)
16+
timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(delay, target, sel, info, repeat)
17+
NSRunLoop.mainRunLoop().addTimer_forMode_(timer, NSRunLoopCommonModes)
18+
return timer
1719

1820
def next_tick(target, sel):
19-
return NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(0, target, sel, None, False)
21+
timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(0, target, sel, None, False)
22+
NSRunLoop.mainRunLoop().addTimer_forMode_(timer, NSRunLoopCommonModes)
2023

2124
from .document import PlotDeviceDocument, PythonScriptDocument, ScriptController
2225
from .app import PlotDeviceAppDelegate

0 commit comments

Comments
 (0)