本文整理汇总了Python中Foundation.NSRunLoop类的典型用法代码示例。如果您正苦于以下问题:Python NSRunLoop类的具体用法?Python NSRunLoop怎么用?Python NSRunLoop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NSRunLoop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: __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)
示例3: 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()
示例4: find_apps_in_dirs
def find_apps_in_dirs(dirlist):
"""Do spotlight search for type applications within the
list of directories provided. Returns a list of paths to applications
these appear to always be some form of unicode string.
"""
applist = []
query = NSMetadataQuery.alloc().init()
query.setPredicate_(
NSPredicate.predicateWithFormat_('(kMDItemKind = "Application")'))
query.setSearchScopes_(dirlist)
query.startQuery()
# Spotlight isGathering phase - this is the initial search. After the
# isGathering phase Spotlight keeps running returning live results from
# filesystem changes, we are not interested in that phase.
# Run for 0.3 seconds then check if isGathering has completed.
runtime = 0
maxruntime = 20
while query.isGathering() and runtime <= maxruntime:
runtime += 0.3
NSRunLoop.currentRunLoop(
).runUntilDate_(NSDate.dateWithTimeIntervalSinceNow_(0.3))
query.stopQuery()
if runtime >= maxruntime:
display.display_warning(
'Spotlight search for applications terminated due to excessive '
'time. Possible causes: Spotlight indexing is turned off for a '
'volume; Spotlight is reindexing a volume.')
for item in query.results():
pathname = item.valueForAttribute_('kMDItemPath')
if pathname and not is_excluded_filesystem(pathname):
applist.append(pathname)
return applist
示例5: 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:")
示例6: 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
示例7: isDone
def isDone(self):
'''Check if the connection request is complete. As a side effect,
allow the delegates to work by letting the run loop run for a bit'''
if self.done:
return self.done
# let the delegates do their thing
NSRunLoop.currentRunLoop().runUntilDate_(
NSDate.dateWithTimeIntervalSinceNow_(.1))
return self.done
示例8: 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)
示例9: _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)
示例10: _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)
示例11: 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
示例12: finishLaunching
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).")
示例13: _NH_MediaStreamDidStart
def _NH_MediaStreamDidStart(self, sender, data):
super(VideoController, self)._NH_MediaStreamDidStart(sender, data)
self.started = True
sample_rate = self.stream.clock_rate/1000
codec = beautify_video_codec(self.stream.codec)
self.sessionController.log_info("Video stream established to %s:%s using %s %0.fkHz codec" % (self.stream.remote_rtp_address, self.stream.remote_rtp_port, codec, sample_rate))
self.videoWindowController.show()
self.changeStatus(STREAM_CONNECTED)
if self.sessionController.hasStreamOfType("chat") and self.videoWindowController.always_on_top:
self.videoWindowController.toogleAlwaysOnTop()
self.statistics_timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(STATISTICS_INTERVAL, self, "updateStatisticsTimer:", None, True)
NSRunLoop.currentRunLoop().addTimer_forMode_(self.statistics_timer, NSRunLoopCommonModes)
NSRunLoop.currentRunLoop().addTimer_forMode_(self.statistics_timer, NSEventTrackingRunLoopMode)
示例14: findDomains
def findDomains(serviceName, seconds=5.0):
runloop = NSRunLoop.currentRunLoop()
browser = NSNetServiceBrowser.new()
pbd = PrintingBrowserDelegate.new()
browser.setDelegate_(pbd)
browser.searchForServicesOfType_inDomain_(serviceName, "")
untilWhen = NSDate.dateWithTimeIntervalSinceNow_(seconds)
runloop.runUntilDate_(untilWhen)
示例15: enableAnsweringMachine
def enableAnsweringMachine(self, view, session, run_now=False):
try:
timer = self.answeringMachineTimers[session]
except KeyError:
settings = SIPSimpleSettings()
amLabel = view.viewWithTag_(15)
delay = 0 if run_now else settings.answering_machine.answer_delay
info = dict(delay = delay, session = session, label = amLabel, time = time.time())
timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(1.0, self, "timerTickAnsweringMachine:", info, True)
NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSRunLoopCommonModes)
NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSEventTrackingRunLoopMode)
self.answeringMachineTimers[session] = timer
self.timerTickAnsweringMachine_(timer)
amLabel.setHidden_(False)
else:
if run_now:
self.acceptAudioStreamAnsweringMachine(session)