src/aoikhotkey/hotkey_manager.py
def _hotkey_call(
        self, hotkey, hotkey_type, hotkey_info, event, propagate=None
    ):
        """
        Call hotkey function, catching errors.

        :param hotkey: Hotkey's virtual key list.

        :param hotkey_type: Hotkey type.

        :param hotkey_info: Hotkey info.

        :param event: Event object.

        :param propagate: Whether propagate the event.

        :return: Whether propagate the event.
        """
        # If have hotkey trigger function
        if self._hotkey_tfunc is not None:
            try:
                # Call the hotkey trigger function
                self._hotkey_tfunc(
                    self, hotkey, hotkey_type, hotkey_info, event
                )

            # If have error
            except Exception:
                # Get traceback message
                tb_msg = format_exc()

                # Get error message
                msg = (
                    '# Error when calling trigger function\n'
                    '---\n{}---\n'
                ).format(tb_msg)

                # Print error message
                sys.stderr.write(msg)

        # Get hotkey function
        func = hotkey_info[HOTKEY_INFO_K_HOTKEY_FUNC]

        try:
            # If the hotkey function needs call in main thread
            if tag_call_in_main_thread_exists(func):
                # If the hotkey function needs call with event info
                if tag_call_with_info_exists(func):
                    # Call the hotkey function with event info.
                    # Use the call result to decide whether propagate the
                    # event.
                    propagate = func(
                        hotkey,
                        hotkey_type,
                        hotkey_info,
                        event,
                    )

                # If the hotkey function not needs call with event info
                else:
                    # Call the hotkey function.
                    # Use the call result to decide whether propagate the
                    # event.
                    propagate = func()

            # If the hotkey function not needs call in main thread
            else:
                # If the hotkey function needs call with event info
                if tag_call_with_info_exists(func):
                    # Wrap the hotkey function with event info
                    func = partial(
                        func,
                        hotkey,
                        hotkey_type,
                        hotkey_info,
                        event,
                    )

                # Add the hotkey function to task queue
                add_task(func)

        # If have error
        except Exception:
            # Get traceback message
            tb_msg = format_exc()

            # Get error message
            msg = '# Error calling function in main thread:\n---\n{}---\n'\
                .format(tb_msg)

            # Print error message
            sys.stderr.write(msg)

        # Return whether propagate the event
        return propagate

        Call hotkey function, catching errors.

        :param hotkey: Hotkey's virtual key list.

        :param hotkey_type: Hotkey type.

        :param hotkey_info: Hotkey info.

        :param event: Event object.

        :param propagate: Whether propagate the event.

        :return: Whether propagate the event.
        
Call hotkey function, catching errors.
Call hotkey function catching errors .
def _hotkey_call(
        self, hotkey, hotkey_type, hotkey_info, event, propagate=None
    ):
        if self._hotkey_tfunc is not None:
            try:
                self._hotkey_tfunc(
                    self, hotkey, hotkey_type, hotkey_info, event
                )
            except Exception:
                tb_msg = format_exc()
                msg = (
                    '# Error when calling trigger function\n'
                    '---\n{}---\n'
                ).format(tb_msg)
                sys.stderr.write(msg)
        func = hotkey_info[HOTKEY_INFO_K_HOTKEY_FUNC]
        try:
            if tag_call_in_main_thread_exists(func):
                if tag_call_with_info_exists(func):
                    propagate = func(
                        hotkey,
                        hotkey_type,
                        hotkey_info,
                        event,
                    )
                else:
                    propagate = func()
            else:
                if tag_call_with_info_exists(func):
                    func = partial(
                        func,
                        hotkey,
                        hotkey_type,
                        hotkey_info,
                        event,
                    )
                add_task(func)
        except Exception:
            tb_msg = format_exc()
            msg = '# Error calling function in main thread:\n---\n{}---\n'\
                .format(tb_msg)
            sys.stderr.write(msg)
        return propagate
def _hotkey_call ( self , hotkey , hotkey_type , hotkey_info , event , propagate = None ) : if self . _hotkey_tfunc is not None : try : self . _hotkey_tfunc ( self , hotkey , hotkey_type , hotkey_info , event ) except Exception : tb_msg = format_exc ( ) msg = ( '# Error when calling trigger function\n' '---\n{}---\n' ) . format ( tb_msg ) sys . stderr . write ( msg ) func = hotkey_info [ HOTKEY_INFO_K_HOTKEY_FUNC ] try : if tag_call_in_main_thread_exists ( func ) : if tag_call_with_info_exists ( func ) : propagate = func ( hotkey , hotkey_type , hotkey_info , event , ) else : propagate = func ( ) else : if tag_call_with_info_exists ( func ) : func = partial ( func , hotkey , hotkey_type , hotkey_info , event , ) add_task ( func ) except Exception : tb_msg = format_exc ( ) msg = '# Error calling function in main thread:\n---\n{}---\n' . format ( tb_msg ) sys . stderr . write ( msg ) return propagate
Call hotkey function, catching errors.
Call hotkey function catching errors .
"""
        Call hotkey function, catching errors.

        :param hotkey: Hotkey's virtual key list.

        :param hotkey_type: Hotkey type.

        :param hotkey_info: Hotkey info.

        :param event: Event object.

        :param propagate: Whether propagate the event.

        :return: Whether propagate the event.
        """ # If have hotkey trigger function # Call the hotkey trigger function # If have error # Get traceback message # Get error message # Print error message # Get hotkey function # If the hotkey function needs call in main thread # If the hotkey function needs call with event info # Call the hotkey function with event info. # Use the call result to decide whether propagate the # event. # If the hotkey function not needs call with event info # Call the hotkey function. # Use the call result to decide whether propagate the # event. # If the hotkey function not needs call in main thread # If the hotkey function needs call with event info # Wrap the hotkey function with event info # Add the hotkey function to task queue # If have error # Get traceback message # Get error message # Print error message # Return whether propagate the event
Whether propagate the event.
Whether propagate the event .
self
hotkey
Hotkey's virtual key list.
Hotkey ' s virtual key list .
hotkey_type
None
hotkey_info
None
event
None
propagate
Whether propagate the event.
Whether propagate the event .