HasCallbackProperties

class glue.external.echo.HasCallbackProperties[source]

Bases: object

A class that adds functionality to subclasses that use callback properties.

Methods Summary

add_callback(self, name, callback[, …])

Add a callback that gets triggered when a callback property of the class changes.

add_global_callback(self, callback)

Add a global callback function, which is a callback that gets triggered when any callback properties on the class change.

callback_properties(self)

clear_callbacks(self)

Remove all global and property-specific callbacks.

is_callback_property(self, name)

Whether a property (identified by name) is a callback property.

iter_callback_properties(self)

Iterator to loop over all callback properties.

remove_callback(self, name, callback)

Remove a previously-added callback

remove_global_callback(self, callback)

Remove a global callback function.

Methods Documentation

add_callback(self, name, callback, echo_old=False, priority=0)[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 as callback(new)

priorityint, optional

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

add_global_callback(self, 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(self)[source]
clear_callbacks(self)[source]

Remove all global and property-specific callbacks.

is_callback_property(self, name)[source]

Whether a property (identified by name) is a callback property.

Parameters
namestr

The name of the property to check

iter_callback_properties(self)[source]

Iterator to loop over all callback properties.

remove_callback(self, name, callback)[source]

Remove a previously-added callback

Parameters
namestr

The instance to remove the callback from.

funcfunc

The callback function to remove

remove_global_callback(self, callback)[source]

Remove a global callback function.

Parameters
callbackfunc

The callback function to remove