HasCallbackProperties¶
- class echo.HasCallbackProperties[source]¶
Bases:
objectA class that adds functionality to subclasses that use callback properties.
Methods
add_callback(name, callback[, echo_old, ...])Add a callback that gets triggered when a callback property of the class changes.
add_global_callback(callback)Add a global callback function, which is a callback that gets triggered when any callback properties on the class change.
Return a list of all callback property names.
Remove all global and property-specific callbacks.
is_alias(name)Whether a property (identified by name) is a callback property alias.
is_callback_property(name)Whether a property (identified by name) is a callback property.
Iterator to loop over all callback properties.
remove_callback(name, callback)Remove a previously-added callback
remove_global_callback(callback)Remove a global callback function.
Methods Summary
add_callback(name, callback[, echo_old, ...])Add a callback that gets triggered when a callback property of the class changes.
add_global_callback(callback)Add a global callback function, which is a callback that gets triggered when any callback properties on the class change.
Return a list of all callback property names.
Remove all global and property-specific callbacks.
is_alias(name)Whether a property (identified by name) is a callback property alias.
is_callback_property(name)Whether a property (identified by name) is a callback property.
Iterator to loop over all callback properties.
remove_callback(name, callback)Remove a previously-added callback
remove_global_callback(callback)Remove a global callback function.
Methods Documentation
- add_callback(name, callback, echo_old=False, priority=0, validator=False)[source]¶
Add a callback that gets triggered when a callback property of the class changes.
- Parameters:
- namestr
The instance to add the callback to.
- callbackfunc
The callback function to add
- echo_oldbool, optional
If True, the callback function will be invoked with both the old and new values of the property, as
callback(old, new). If False (the default), will be invoked ascallback(new)- priorityint, optional
This can optionally be used to force a certain order of execution of callbacks (larger values indicate a higher priority).
- validatorbool, optional
Whether the callback is a validator, which is a special kind of callback that gets called before the property is set. The validator can return a modified value (for example it can be used to change the types of values or change properties in-place) or it can also raise an exception.
- add_global_callback(callback)[source]¶
Add a global callback function, which is a callback that gets triggered when any callback properties on the class change.
- Parameters:
- callbackfunc
The callback function to add
- callback_properties()[source]¶
Return a list of all callback property names.
Note: This does not include CallbackPropertyAlias instances, only actual CallbackProperty instances.
- is_alias(name)[source]¶
Whether a property (identified by name) is a callback property alias.
- Parameters:
- namestr
The name of the property to check
- is_callback_property(name)[source]¶
Whether a property (identified by name) is a callback property.
Returns True for both CallbackProperty and CallbackPropertyAlias.
- Parameters:
- namestr
The name of the property to check
- iter_callback_properties()[source]¶
Iterator to loop over all callback properties.
Note: This does not include CallbackPropertyAlias instances, only actual CallbackProperty instances.