当前位置: 首页>>代码示例>>Python>>正文


Python Foundation.NSTimer类代码示例

本文整理汇总了Python中Foundation.NSTimer的典型用法代码示例。如果您正苦于以下问题:Python NSTimer类的具体用法?Python NSTimer怎么用?Python NSTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NSTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_test_timer

 def start_test_timer(self):
   NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
       1,
       self.delegate,
       'timerCallback:',
       None,
       True)
开发者ID:liuzl,项目名称:ulogme,代码行数:7,代码来源:ulogme_osx.py

示例2: run

  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()
开发者ID:liuzl,项目名称:ulogme,代码行数:32,代码来源:ulogme_osx.py

示例3: main

    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."
开发者ID:jcouyang,项目名称:pyTao,代码行数:11,代码来源:camera.py

示例4: __init__

 def __init__(self, image):
     NSBundle.loadNibNamed_owner_("ScreensharingPreviewPanel", self)
     self.view.setImage_(image)
     self.timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(5.0, self, "closeTimer:", None, False)
     NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSModalPanelRunLoopMode)
     NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode)
     self.window.orderFront_(None)
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:7,代码来源:ScreensharingPreviewPanel.py

示例5: applicationDidFinishLaunching_

  def applicationDidFinishLaunching_(self, notification):
    self.noDevice = None

    #Create menu
    self.menu = NSMenu.alloc().init()

    self.barItem = dict()

    # Load images
    self.noDeviceImage = NSImage.alloc().initByReferencingFile_('icons/no_device.png')
    self.barImage = dict(kb = NSImage.alloc().initByReferencingFile_('icons/kb.png'),
			 magicMouse = NSImage.alloc().initByReferencingFile_('icons/magic_mouse.png'),
			 mightyMouse = NSImage.alloc().initByReferencingFile_('icons/mighty_mouse.png'),
			 magicTrackpad = NSImage.alloc().initByReferencingFile_('icons/TrackpadIcon.png'))

    #Define menu items
    self.statusbar = NSStatusBar.systemStatusBar()
    self.menuAbout = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('About BtBatStat', 'about:', '')
    self.separator_menu_item = NSMenuItem.separatorItem()
    self.menuQuit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '')

    # Get the timer going
    self.timer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_(start_time, 10.0, self, 'tick:', None, True)
    NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode)
    self.timer.fire()

    #Add menu items
    self.menu.addItem_(self.menuAbout)
    self.menu.addItem_(self.separator_menu_item)
    self.menu.addItem_(self.menuQuit)

    #Check for updates
    checkForUpdates()
开发者ID:Ku2f,项目名称:btbatstat,代码行数:33,代码来源:BtBatStat.py

示例6: end

    def end(self):
        if self.ended:
            return

        self.sessionController.log_debug(u"End %s" % self)

        self.ended = True

        NSApp.delegate().contactsWindowController.hideLocalVideoWindow()
        status = self.status
        if status in [STREAM_IDLE, STREAM_FAILED]:
            self.changeStatus(STREAM_IDLE)
        elif status == STREAM_PROPOSING:
            self.sessionController.cancelProposal(self.stream)
            self.changeStatus(STREAM_CANCELLING)
        else:
            self.sessionController.endStream(self)
            self.changeStatus(STREAM_IDLE)

        self.removeFromSession()
        self.videoWindowController.close()
        self.notification_center.discard_observer(self, sender=self.sessionController)

        dealloc_timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(5.0, self, "deallocTimer:", None, False)
        NSRunLoop.currentRunLoop().addTimer_forMode_(dealloc_timer, NSRunLoopCommonModes)
        NSRunLoop.currentRunLoop().addTimer_forMode_(dealloc_timer, NSEventTrackingRunLoopMode)
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:26,代码来源:VideoController.py

示例7: start

 def start(self):
     if not self._status:
         self._nsdate = NSDate.date()
         self._nstimer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_(
             self._nsdate, self._interval, self, 'callback:', None, True)
         NSRunLoop.currentRunLoop().addTimer_forMode_(self._nstimer, NSDefaultRunLoopMode)
         _TIMERS.add(self)
         self._status = True
开发者ID:philippeowagner,项目名称:rumps,代码行数:8,代码来源:rumps.py

示例8: awakeFromNib

    def awakeFromNib(self):
        NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "contactSelectionChanged:", NSTableViewSelectionDidChangeNotification, self.contactTable)

        timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(0.3, self, "refreshContactsTimer:", None, True)
        NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSModalPanelRunLoopMode)
        NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSDefaultRunLoopMode)

        self.contactTable.setDoubleAction_("doubleClick:")
开发者ID:uditha-atukorala,项目名称:blink,代码行数:8,代码来源:HistoryViewer.py

示例9: applicationDidFinishLaunching_

 def applicationDidFinishLaunching_(self, _):
     NSLog("applicationDidFinishLaunching_")
     self.timer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
         1.0 / self.FRAMERATE,
                 self.view,
                 self.view.animate_,
                 None,
                 True
                 )
开发者ID:chayapan,项目名称:minimal-pyobjc,代码行数:9,代码来源:ApplicationDelegate.py

示例10: stopEventLoop

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
开发者ID:BMXE,项目名称:music-player,代码行数:18,代码来源:AppHelper.py

示例11: enableAutoAnswer

 def enableAutoAnswer(self, view, session, delay=30):
     if session not in self.autoAnswerTimers:
         label = view.viewWithTag_(15)
         info = dict(delay = delay, session = session, label = label, time = time.time())
         timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(1.0, self, "timerTickAutoAnswer:", info, True)
         NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSRunLoopCommonModes)
         NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSEventTrackingRunLoopMode)
         self.autoAnswerTimers[session] = timer
         self.timerTickAutoAnswer_(timer)
         label.setHidden_(False)
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:10,代码来源:AlertPanel.py

示例12: _finish

 def _finish(self):
     self.smp_running = False
     self.finished = True
     self.secretText.setEnabled_(False)
     self.questionText.setEnabled_(False)
     self.progressBar.setDoubleValue_(9)
     self.continueButton.setEnabled_(True)
     self.continueButton.setTitle_('Finish')
     self.cancelButton.setHidden_(True)
     self.timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(5, self, "verificationFinished:", None, False)
     NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSRunLoopCommonModes)
开发者ID:uditha-atukorala,项目名称:blink,代码行数:11,代码来源:ChatOTR.py

示例13: _NH_SIPApplicationDidStart

    def _NH_SIPApplicationDidStart(self, notification):
        settings = SIPSimpleSettings()
        if settings.presence_state.timestamp is None:
            settings.presence_state.timestamp = ISOTimestamp.now()
            settings.save()

        self.get_location([account for account in AccountManager().iter_accounts() if account is not BonjourAccount()])
        self.publish()

        idle_timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(1.0, self, "updateIdleTimer:", None, True)
        NSRunLoop.currentRunLoop().addTimer_forMode_(idle_timer, NSRunLoopCommonModes)
        NSRunLoop.currentRunLoop().addTimer_forMode_(idle_timer, NSEventTrackingRunLoopMode)
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:12,代码来源:PresencePublisher.py

示例14: textDidChange_

 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)
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:13,代码来源:ChatViewController.py

示例15: start

    def start(self):
        notification_center = NotificationCenter()
        notification_center.add_observer(self, name="BlinkFileTransferDidEnd")
        notification_center.add_observer(self, name="AudioStreamDidChangeHoldState")
        notification_center.add_observer(self, name="CFGSettingsObjectDidChange")
        notification_center.add_observer(self, name="ChatViewControllerDidDisplayMessage")
        notification_center.add_observer(self, name="ConferenceHasAddedAudio")
        notification_center.add_observer(self, name="BlinkWillCancelProposal")

        self.cleanupTimer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(3, self, "cleanupTimer:", None, True)
        NSRunLoop.currentRunLoop().addTimer_forMode_(self.cleanupTimer, NSRunLoopCommonModes)
        NSRunLoop.currentRunLoop().addTimer_forMode_(self.cleanupTimer, NSEventTrackingRunLoopMode)
        self.started = True
开发者ID:uditha-atukorala,项目名称:blink,代码行数:13,代码来源:SessionRinger.py


注:本文中的Foundation.NSTimer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。