Python PyObjCTools.AppHelper.stopEventLoop() Examples

The following are 5 code examples of PyObjCTools.AppHelper.stopEventLoop(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyObjCTools.AppHelper , or try the search function .
Example #1
Source File: tilt_monitor_macos.py    From fermentrack with MIT License 5 votes vote down vote up
def _runMainRunLoop(self):
        # Create background thread to run user code.
        self._user_thread = threading.Thread(target=self._user_thread_main)
        self._user_thread.daemon = True
        self._user_thread.start()
        # Run main loop.  This call will never return!
        try:
            AppHelper.runConsoleEventLoop(installInterrupt=True)
        except KeyboardInterrupt:
            AppHelper.stopEventLoop()
            sys.exit(0) 
Example #2
Source File: provider.py    From Adafruit_Python_BluefruitLE with MIT License 5 votes vote down vote up
def run_mainloop_with(self, target):
        """Start the OS's main loop to process asyncronous BLE events and then
        run the specified target function in a background thread.  Target
        function should be a function that takes no parameters and optionally
        return an integer response code.  When the target function stops
        executing or returns with value then the main loop will be stopped and
        the program will exit with the returned code.

        Note that an OS main loop is required to process asyncronous BLE events
        and this function is provided as a convenience for writing simple tools
        and scripts that don't need to be full-blown GUI applications.  If you
        are writing a GUI application that has a main loop (a GTK glib main loop
        on Linux, or a Cocoa main loop on OSX) then you don't need to call this
        function.
        """
        # Create background thread to run user code.
        self._user_thread = threading.Thread(target=self._user_thread_main,
                                             args=(target,))
        self._user_thread.daemon = True
        self._user_thread.start()
        # Run main loop.  This call will never return!
        try:
            AppHelper.runConsoleEventLoop(installInterrupt=True)
        except KeyboardInterrupt:
            AppHelper.stopEventLoop()
            sys.exit(0) 
Example #3
Source File: nsss.py    From pyttsx3 with GNU General Public License v3.0 5 votes vote down vote up
def endLoop(self):
        AppHelper.stopEventLoop() 
Example #4
Source File: gui_mac.py    From ComicStreamer with Apache License 2.0 5 votes vote down vote up
def about(self, sender):
        #rumps.alert("My quit message")
        self.apiServer.shutdown()
        AppHelper.stopEventLoop()
        print "after stop"
        
    
    #@rumps.clicked("Arbitrary", "Depth", "It's pretty easy")  # very simple to access nested menu items
    #def does_something(self, sender):
    #    my_data = {'poop': 88}
    #    rumps.notification(title='Hi', subtitle='There.', message='Friend!',  data=my_data)
    
    
    #@rumps.clicked("Preferences")
    #def not_actually_prefs(self, sender):
    #    if not sender.icon:
    #        sender.icon = 'level_4.png'
    #    sender.state = not sender.state
    
    
    #@rumps.timer(4)  # create a new thread that calls the decorated function every 4 seconds
    #def write_unix_time(self, sender):
    #    with self.rumps_app.open('times', 'a') as f:  # this opens files in your app's Application Support folder
    #        f.write('The unix time now: {}\n'.format(time.time()))
    
    
    #@rumps.clicked("Arbitrary")
    #def change_statusbar_title(self, sender):
    #    app.title = 'Hello World' if self.rumps_app.title != 'Hello World' else 'World, Hello' 
Example #5
Source File: macos_adapter.py    From python-bleson with MIT License 5 votes vote down vote up
def centralManager_didDisconnectPeripheral_error_(self, manager, peripheral, error):
        log.debug("centralManager_didDisconnectPeripheral_error_")
        self.connected = False
        #AppHelper.stopEventLoop()