Exemple #1
0
    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)
        notifications._init_nsapp(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.installMachInterrupt()
        AppHelper.runEventLoop()
Exemple #2
0
def main():
    # This gets Ctrl-C handling working when we're in the
    # CFRunLoop.
    AppHelper.installMachInterrupt()

    port = _make_tap_port()
    assert port is not None
    run_source = _make_run_loop_source(port)

    assert run_source is not None
    _run_run_loop()
Exemple #3
0
    def show(self):
        pool = NSAutoreleasePool.alloc().init()
        Debugging.installVerboseExceptionHandler()
        AppHelper.installMachInterrupt()
        self.window.orderFrontRegardless()

        print time.ctime(), "Cocoa: Starting event loop..."
        try:
            NSApp().run()
        except KeyboardInterrupt:
            print time.ctime(), "Interrupted."
        finally:
            print time.ctime(), "Cocoa: Event loop ended."
        del pool
Exemple #4
0
	def show(self):
		pool = NSAutoreleasePool.alloc().init()
		Debugging.installVerboseExceptionHandler()
		AppHelper.installMachInterrupt()
		self.window.orderFrontRegardless()

		print time.ctime(), "Cocoa: Starting event loop..."
		try:
			NSApp().run()
		except KeyboardInterrupt:
			print time.ctime(), "Interrupted."
		finally:
			print time.ctime(), "Cocoa: Event loop ended."
		del pool
Exemple #5
0
 def runModal(self, title, message, help_link, text = ''):
     pool = NSAutoreleasePool.alloc().init()
     try:
         app = NSApplication.sharedApplication()
         if app.isRunning():
             death_event = Event()
             app_delegate = BootErrorAppDelegate(title, message, help_link, text, death_event)
             AppHelper.callAfter(app_delegate.applicationWillFinishLaunching_, None)
             death_event.wait()
         else:
             AppHelper.installMachInterrupt()
             app_delegate = BootErrorAppDelegate(title, message, help_link, text, None)
             app.setDelegate_(app_delegate)
             AppHelper.runEventLoop()
     finally:
         del pool
Exemple #6
0
    def first_show(self):
        if not self.hidden:
            self.window.makeKeyAndOrderFront_(self.window)
        else:
            self.hidden = False

        if self.minimized:
            self.minimize()

        if not BrowserView.app.isRunning():
            # Add the default Cocoa application menu
            self._add_app_menu()
            self._add_view_menu()

            BrowserView.app.activateIgnoringOtherApps_(Foundation.YES)
            AppHelper.installMachInterrupt()
            BrowserView.app.run()
Exemple #7
0
    def mainloop(self):
        real_self = self
        app = NSApplication.sharedApplication()

        class ApplicationDelegate(NSObject):

            def __new__(cls):
                return ApplicationDelegate.alloc().init()

            def applicationWillFinishLaunching_(self, notication):
                real_self._make_main_menu()

            def applicationDidFinishLaunching_(self, notication):
                pass

        holder = ApplicationDelegate()
        app.setDelegate_(holder)
        AppHelper.installMachInterrupt()
        AppHelper.runEventLoop()
        self.no_dispatch = True