當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。