예제 #1
0
def register_callback(module_hdl,
                      callback_type,
                      py_callback,
                      first_param=None,
                      second_param=None):
    """Register a callback. For a richer interface, use the CallbackManager class.

        :param module_hdl: The module handle provided to the script as parameter to the initialize_callbacks function.
                           Use 0 if it doesn't apply.
        :type module_hdl: int

        :param callback_type: The callback type. See callback type constants referenced in the API module (ending on CB)
        :type callback_type: int

        :param py_callback: Callback function.
        :type py_callback: function

        :return: Callback handle for the registered callback, that can be used to unregister it.
        :rtype: int
    """
    import c_api
    if first_param is None:
        return c_api.register_callback(module_hdl, callback_type, py_callback)
    elif second_param is None:
        return c_api.register_callback(module_hdl, callback_type, py_callback,
                                       first_param)
    else:
        return c_api.register_callback(module_hdl, callback_type, py_callback,
                                       first_param, second_param)
예제 #2
0
def register_callback(
        module_hdl,
        callback_type,
        py_callback,
        first_param=None,
        second_param=None):
    """Register a callback. For a richer interface, use the CallbackManager class.

        :param module_hdl: The module handle provided to the script as parameter to the initialize_callbacks function.
                           Use 0 if it doesn't apply.
        :type module_hdl: int

        :param callback_type: The callback type. See callback type constants referenced in the API module (ending on CB)
        :type callback_type: int

        :param py_callback: Callback function.
        :type py_callback: function

        :return: Callback handle for the registered callback, that can be used to unregister it.
        :rtype: int
    """
    import c_api
    if first_param is None:
        return c_api.register_callback(module_hdl, callback_type, py_callback)
    elif second_param is None:
        return c_api.register_callback(
            module_hdl, callback_type, py_callback, first_param)
    else:
        return c_api.register_callback(
            module_hdl,
            callback_type,
            py_callback,
            first_param,
            second_param)