def setTimeToGiveUp_(self, time): """Configure alert to give up after time seconds.""" # Cocoa objects must use class func alloc().init(), so pylint # doesn't see our init(). # pylint: disable=attribute-defined-outside-init self.timer = \ NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_( time, self, "_killWindow", None, False)
def setTimeToGiveUp_(self, time): """Configure alert to give up after time seconds.""" # Cocoa objects must use class func alloc().init(), so pylint # doesn't see our init(). # pylint: disable=attribute-defined-outside-init self.timer = \ NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_( time, self, "_killWindow", None, False)
def setFlash_(self, on): if on and self.flash_timer is None: self.flashing_state = True self.flash_timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(0.5, self, self.updateStatusImage_, ('flash',), True) self.flash_timer.fire() NSRunLoop.currentRunLoop().addTimer_forMode_(self.flash_timer, NSDefaultRunLoopMode) elif not on and self.flashing_state is not None: if self.flash_timer is not None: self.flash_timer.invalidate() self.flash_timer = None self.flashing_state = None self.setNeedsDisplay_(1)
def initWithStartVal_endVal_duration_interval_valueCb_doneCb_(self, start_val, end_val, duration, update_period, value_callback, done_callback): self = super(LinearAnimator, self).init() if not self: return self.start_time = time.time() self.duration = duration self.end_val = end_val self.start_val = start_val self.value_callback = value_callback self.done_callback = done_callback self.timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(update_period, self, 'period:', None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSEventTrackingRunLoopMode) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode)
def updateIcon_(self, icon_state): target_image = self.ICON_MAP.get(icon_state) assert target_image is not None, 'invalid icon state' if target_image in ('busy', 'cam'): self.busy_timer_image = target_image if self.busy_timer is None: self.busy_timer_state = 5 self.busy_timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(0.4, self, self.updateStatusImage_, ('busy',), True) self.busy_timer.fire() NSRunLoop.currentRunLoop().addTimer_forMode_(self.busy_timer, NSDefaultRunLoopMode) else: if self.busy_timer is not None: self.busy_timer.invalidate() self.busy_timer = None self.updateStatusImage_((target_image,))
def startWatchdog(): watchdog = WatchdogTimer.alloc().init() interval = 0.5 timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_( interval, watchdog, 'tick:', None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSDefaultRunLoopMode)