本文整理汇总了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()