本文整理匯總了Python中PyObjCTools.AppHelper.runEventLoop方法的典型用法代碼示例。如果您正苦於以下問題:Python AppHelper.runEventLoop方法的具體用法?Python AppHelper.runEventLoop怎麽用?Python AppHelper.runEventLoop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyObjCTools.AppHelper
的用法示例。
在下文中一共展示了AppHelper.runEventLoop方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from PyObjCTools import AppHelper [as 別名]
# 或者: from PyObjCTools.AppHelper import runEventLoop [as 別名]
def run(self):
"""
Perform various setup tasks then start application run loop.
"""
nsapplication = NSApplication.sharedApplication()
nsapplication.activateIgnoringOtherApps_(True) # NSAlerts in front
self._nsapp = NSApp.alloc().init()
self._nsapp._app = self.__dict__ # allow for dynamic modification based on this App instance
self._nsapp.initializeStatusBar()
nsapplication.setDelegate_(self._nsapp)
#NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self._nsapp)
setattr(App, '*app_instance', self) # class level ref to running instance (for passing self to App subclasses)
t = b = None
for t in getattr(timer, '*timers', []):
t.start()
for b in getattr(clicked, '*buttons', []):
b(self) # we waited on registering clicks so we could pass self to access _menu attribute
del t, b
AppHelper.runEventLoop()
#sys.exit(0)
示例2: serve_forever
# 需要導入模塊: from PyObjCTools import AppHelper [as 別名]
# 或者: from PyObjCTools.AppHelper import runEventLoop [as 別名]
def serve_forever():
app = NSApplication.sharedApplication()
delegate = MacTrayObject.alloc().init()
app.setDelegate_(delegate)
AppHelper.runEventLoop()
示例3: install
# 需要導入模塊: from PyObjCTools import AppHelper [as 別名]
# 或者: from PyObjCTools.AppHelper import runEventLoop [as 別名]
def install(runLoop=None, runner=None):
"""
Configure the twisted mainloop to be run inside CFRunLoop.
@param runLoop: the run loop to use.
@param runner: the function to call in order to actually invoke the main
loop. This will default to C{CFRunLoopRun} if not specified. However,
this is not an appropriate choice for GUI applications, as you need to
run NSApplicationMain (or something like it). For example, to run the
Twisted mainloop in a PyObjC application, your C{main.py} should look
something like this::
from PyObjCTools import AppHelper
from twisted.internet.cfreactor import install
install(runner=AppHelper.runEventLoop)
# initialize your application
reactor.run()
@return: The installed reactor.
@rtype: C{CFReactor}
"""
reactor = CFReactor(runLoop=runLoop, runner=runner)
from twisted.internet.main import installReactor
installReactor(reactor)
return reactor
示例4: main
# 需要導入模塊: from PyObjCTools import AppHelper [as 別名]
# 或者: from PyObjCTools.AppHelper import runEventLoop [as 別名]
def main():
app = NSApplication.sharedApplication()
delegate = AppDelegate.alloc().init()
NSApp().setDelegate_(delegate)
AppHelper.callLater(_BUCKET_SIZE_SECONDS, record)
AppHelper.runEventLoop()
示例5: install
# 需要導入模塊: from PyObjCTools import AppHelper [as 別名]
# 或者: from PyObjCTools.AppHelper import runEventLoop [as 別名]
def install(runLoop=None, runner=None):
"""
Configure the twisted mainloop to be run inside CFRunLoop.
@param runLoop: the run loop to use.
@param runner: the function to call in order to actually invoke the main
loop. This will default to L{CFRunLoopRun} if not specified. However,
this is not an appropriate choice for GUI applications, as you need to
run NSApplicationMain (or something like it). For example, to run the
Twisted mainloop in a PyObjC application, your C{main.py} should look
something like this::
from PyObjCTools import AppHelper
from twisted.internet.cfreactor import install
install(runner=AppHelper.runEventLoop)
# initialize your application
reactor.run()
@return: The installed reactor.
@rtype: L{CFReactor}
"""
reactor = CFReactor(runLoop=runLoop, runner=runner)
from twisted.internet.main import installReactor
installReactor(reactor)
return reactor
示例6: run
# 需要導入模塊: from PyObjCTools import AppHelper [as 別名]
# 或者: from PyObjCTools.AppHelper import runEventLoop [as 別名]
def run(self, **options):
"""Performs various setup tasks including creating the underlying Objective-C application, starting the timers,
and registering callback functions for click events. Then starts the application run loop.
.. versionchanged:: 0.2.1
Accepts `debug` keyword argument.
:param debug: determines if application should log information useful for debugging. Same effect as calling
:func:`rumps.debug_mode`.
"""
dont_change = object()
debug = options.get('debug', dont_change)
if debug is not dont_change:
debug_mode(debug)
nsapplication = NSApplication.sharedApplication()
nsapplication.activateIgnoringOtherApps_(True) # NSAlerts in front
self._nsapp = NSApp.alloc().init()
self._nsapp._app = self.__dict__ # allow for dynamic modification based on this App instance
nsapplication.setDelegate_(self._nsapp)
if _NOTIFICATIONS:
try:
notification_center = _default_user_notification_center()
except RuntimeError:
pass
else:
notification_center.setDelegate_(self._nsapp)
setattr(App, '*app_instance', self) # class level ref to running instance (for passing self to App subclasses)
t = b = None
for t in getattr(timer, '*timers', []):
t.start()
for b in getattr(clicked, '*buttons', []):
b(self) # we waited on registering clicks so we could pass self to access _menu attribute
del t, b
self._nsapp.initializeStatusBar()
AppHelper.runEventLoop()
示例7: run
# 需要導入模塊: from PyObjCTools import AppHelper [as 別名]
# 或者: from PyObjCTools.AppHelper import runEventLoop [as 別名]
def run(self):
app = NSApplication.sharedApplication()
osxthing = MacOSXThing.alloc().init()
osxthing.indicator = self
app.setDelegate_(osxthing)
try:
AppHelper.runEventLoop()
except:
traceback.print_exc()