Inherits from
- Delegate: enthought.traits.trait_types.Delegate
Attributes
Inherited from base classes
Method summary
- __init__(self, delegate, prefix = '', listenable = True, **metadata)
Inherited from base classes
- arg_error(self, method, arg_num, object, name, value)
- create_editor(self)
- dup_arg_error(self, method, arg_num, object, name)
- error(self, object, name, value)
- full_info(self, object, name, value)
- get_editor(self, trait = None)
- info(self)
- inner_traits(self)
- is_valid(self, object, name, value)
- keyword_error(self, method, object, name, value)
- missing_arg_error(self, method, arg_num, object, name)
- repr(self, value)
- return_error(self, method, object, value)
Methods
- __init__(self, delegate, prefix = '', listenable = True, **metadata)
Creates a "delegator" trait, whose definition and default value are delegated to a delegate trait attribute on another object.
Parameters
- delegate : string
- Name of the attribute on the current object which references the object that is the trait's delegate
- prefix : string
- A prefix or substitution applied to the original attribute when looking up the delegated attribute
- listenable : Boolean
- Indicates whether a listener can be attached to this attribute such that changes to the delagate attribute will trigger it
Description
An object containing a delegator trait attribute must contain a second attribute that references the object containing the delegate trait attribute. The name of this second attribute is passed as the delegate argument to the DelegatesTo() function.
The following rules govern the application of the prefix parameter:
- If prefix is empty or omitted, the delegation is to an attribute of the delegate object with the same name as the delegator attribute.
- If prefix is a valid Python attribute name, then the delegation is to an attribute whose name is the value of prefix.
- If prefix ends with an asterisk ('*') and is longer than one character, then the delegation is to an attribute whose name is the value of prefix, minus the trailing asterisk, prepended to the delegator attribute name.
- If prefix is equal to a single asterisk, the delegation is to an attribute whose name is the value of the delegator object's __prefix__ attribute prepended to delegator attribute name.
Note that any changes to the delegator attribute are actually applied to the corresponding attribute on the delegate object. The original object containing the delegator trait is not modified.