DictCallbackProperty

class echo.DictCallbackProperty(default=None, docstring=None, getter=None, setter=None)[source]

Bases: CallbackProperty

A dictionary property that calls callbacks when its contents are modified

Methods

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

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)

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

Methods Documentation

add_callback(instance, func, echo_old=False, priority=0)

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 as func(new)

priorityint, optional

This can optionally be used to force a certain order of execution of callbacks (larger values indicate a higher priority).

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_old was set to True when calling add_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