SelectionCallbackProperty¶
- class echo.SelectionCallbackProperty(default_index=0, choices=None, display_func=None, comparison_type=None, **kwargs)[source]¶
Bases:
CallbackPropertyMethods
add_callback(instance, func[, echo_old, ...])Add a callback to a specific instance that manages this property
clear_callbacks(instance)Remove all callbacks on this property.
disable(instance)Disable callbacks for a specific instance
enable(instance)Enable previously-disabled callbacks for a specific instance
notify(instance, old, new)Call all callback functions with the current value
remove_callback(instance, func)Remove a previously-added callback
setter(func)Method to use as a decorator, to mimic @property.setter
enabled
force_next_sync
get_choice_labels
get_choices
get_display_func
set_choices
set_display_func
Methods Summary
add_callback(instance, func[, echo_old, ...])Add a callback to a specific instance that manages this property
clear_callbacks(instance)Remove all callbacks on this property.
disable(instance)Disable callbacks for a specific instance
enable(instance)Enable previously-disabled callbacks for a specific instance
enabled(instance)force_next_sync(instance)get_choice_labels(instance)get_choices(instance)get_display_func(instance)notify(instance, old, new)Call all callback functions with the current value
remove_callback(instance, func)Remove a previously-added callback
set_choices(instance, choices)set_display_func(instance, display)setter(func)Method to use as a decorator, to mimic @property.setter
Methods Documentation
- add_callback(instance, func, echo_old=False, priority=0, validator=False)¶
Add a callback to a specific instance that manages this property
- Parameters:
- instance
The instance to add the callback to
- funcfunc
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
func(old, new). If False (the default), will be invoked asfunc(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.
- clear_callbacks(instance)¶
Remove all callbacks on this property.
- disable(instance)¶
Disable callbacks for a specific instance
- enable(instance)¶
Enable previously-disabled callbacks for a specific instance
- enabled(instance)¶
- notify(instance, old, new)¶
Call all callback functions with the current value
Each callback will either be called using callback(new) or callback(old, new) depending on whether
echo_oldwas set to True when callingadd_callback()- Parameters:
- instance
The instance to consider
- old
The old value of the property
- new
The new value of the property
- remove_callback(instance, func)¶
Remove a previously-added callback
- Parameters:
- instance
The instance to detach the callback from
- funcfunc
The callback function to remove
- setter(func)¶
Method to use as a decorator, to mimic @property.setter