本文整理汇总了Python中Foundation.NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_方法的典型用法代码示例。如果您正苦于以下问题:Python NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_方法的具体用法?Python NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_怎么用?Python NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundation.NSTimer
的用法示例。
在下文中一共展示了NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_test_timer
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def start_test_timer(self):
NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
1,
self.delegate,
'timerCallback:',
None,
True)
示例2: run
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def run(self):
NSApplication.sharedApplication()
self.delegate = AppDelegate.alloc().init()
self.delegate.event_sniffer = self
NSApp().setDelegate_(self.delegate)
self.workspace = NSWorkspace.sharedWorkspace()
nc = self.workspace.notificationCenter()
# This notification needs OS X v10.6 or later
nc.addObserver_selector_name_object_(
self.delegate,
'applicationActivated:',
'NSWorkspaceDidActivateApplicationNotification',
None)
nc.addObserver_selector_name_object_(
self.delegate,
'screenSleep:',
'NSWorkspaceScreensDidSleepNotification',
None)
# I don't think we need to track when the screen comes awake, but in case
# we do we can listen for NSWorkspaceScreensDidWakeNotification
NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
self.options.active_window_time, self.delegate, 'writeActiveApp:',
None, True)
# Start the application. This doesn't return.
AppHelper.runEventLoop()
示例3: main
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def main(self):
# Callback that quits after a frame is captured
NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(0.1, self, "quitMainLoop:", None, True)
# Turn on the camera and start the capture
self.startImageCapture(None)
# Start Cocoa's main event loop
AppHelper.runConsoleEventLoop(installInterrupt=True)
print "Frame capture completed."
示例4: stopEventLoop
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def stopEventLoop():
"""
Stop the current event loop if possible
returns True if it expects that it was successful, False otherwise
"""
stopper = PyObjCAppHelperRunLoopStopper.currentRunLoopStopper()
if stopper is None:
if NSApp() is not None:
NSApp().terminate_(None)
return True
return False
NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
0.0,
stopper,
'performStop:',
None,
False)
return True
示例5: applicationDidFinishLaunching_
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def applicationDidFinishLaunching_(self, _):
NSLog("applicationDidFinishLaunching_")
self.timer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
1.0 / self.FRAMERATE,
self.view,
self.view.animate_,
None,
True
)
示例6: textDidChange_
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def textDidChange_(self, notification):
self.lastTypedTime = datetime.datetime.now()
if self.inputText.textStorage().length() == 0:
self.becameIdle_(None)
else:
if not self.lastTypeNotifyTime or time.time() - self.lastTypeNotifyTime > TYPING_NOTIFY_INTERVAL:
self.lastTypeNotifyTime = time.time()
self.delegate.chatView_becameActive_(self, self.lastTypedTime)
if self.typingTimer:
# delay the timeout a bit more
self.typingTimer.setFireDate_(NSDate.dateWithTimeIntervalSinceNow_(TYPING_IDLE_TIMEOUT))
else:
self.typingTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(TYPING_IDLE_TIMEOUT, self, "becameIdle:", None, False)
示例7: isScrolling_
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def isScrolling_(self, scrollTop):
if not self.handle_scrolling:
return
if self.editorVisible:
return
if scrollTop < 0:
if self.scrollingTimer is None:
self.scrollingTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(1, self, "scrollTimerDelay:", None, False)
self.scrolling_back = True
else:
self.scrolling_back = False
if self.scrollingTimer is not None:
self.scrollingTimer.invalidate()
self.scrollingTimer = None
if scrollTop == 0 and self.handle_scrolling:
current_label = self.lastMessagesLabel.stringValue()
new_label = NSLocalizedString("Keep scrolling up for more than one second to load older messages", "Label")
if current_label != new_label and NSLocalizedString("Loading", "Label") not in current_label:
self.lastMessagesLabel.setStringValue_(new_label)
NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(4, self, "showLastScrollLabel:", None, False)
示例8: finishLaunching
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def finishLaunching(self):
"""Setup the menu and run the app loop."""
self._setup_menu_bar()
# Create a timer which fires the update_ method every 1second,
# and add it to the runloop
NSRunLoop.currentRunLoop().addTimer_forMode_(
NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(1, self, "update:", "", True),
NSEventTrackingRunLoopMode,
)
print("Sentinel is now running.")
print("CTRL+C does not work here.")
print("You can quit through the menu bar (Sentinel -> Quit).")
示例9: gotIsComposing
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def gotIsComposing(self, window, state, refresh, last_active):
self.enableIsComposing = True
flag = state == "active"
if flag:
if refresh is None:
refresh = 120
if last_active is not None and (last_active - ISOTimestamp.now() > datetime.timedelta(seconds=refresh)):
# message is old, discard it
return
if self.remoteTypingTimer:
# if we don't get any indications in the request refresh, then we assume remote to be idle
self.remoteTypingTimer.setFireDate_(NSDate.dateWithTimeIntervalSinceNow_(refresh))
else:
self.remoteTypingTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(refresh, self, "remoteBecameIdle:", window, False)
else:
if self.remoteTypingTimer:
self.remoteTypingTimer.invalidate()
self.remoteTypingTimer = None
window.noteView_isComposing_(self, flag)
示例10: sleep
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def sleep(self, timeout):
NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
timeout, self, "timedOut:", None, False)
self.timedout = False
waituntil(lambda: self.timedout)
示例11: runTimer
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def runTimer(target, selector, interval):
return NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(interval,target,selector,None,True)
示例12: __init__
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def __init__(self):
NSBundle.loadNibNamed_owner_("VideoDisconnectWindow", self)
self.window.setAlphaValue_(0.7)
timer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(0.05, self, "fade:", None, True)
示例13: set_timeout
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def set_timeout(target, sel, delay, info=None, repeat=False):
return NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(delay, target, sel, info, repeat)
示例14: startFadeTimer
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def startFadeTimer(self):
self.visible = False
if self.fade_timer is None:
self.fade_timer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(0.05, self, "fade:", None, True)
NSRunLoop.currentRunLoop().addTimer_forMode_(self.fade_timer, NSRunLoopCommonModes)
NSRunLoop.currentRunLoop().addTimer_forMode_(self.fade_timer, NSEventTrackingRunLoopMode)
示例15: windowShouldClose_
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ [as 别名]
def windowShouldClose_(self, sender):
self.visible = False
if self.close_timer is None:
self.close_timer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(0.05, self, "fade:", None, True)
return False