Inherits from
- Delegate: enthought.traits.trait_types.Delegate
Attributes
Inherited from base classes
Method summary
- __init__(self, prototype, 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, prototype, prefix = '', listenable = True, **metadata)
Creates a "prototyped" trait, whose definition and default value are obtained from a trait attribute on another object.
Parameters
- prototype : string
- Name of the attribute on the current object which references the object that is the trait's prototype
- prefix : string
- A prefix or substitution applied to the original attribute when looking up the prototyped attribute
- listenable : Boolean
- Indicates whether a listener can be attached to this attribute such that changes to the corresponding attribute on the prototype object will trigger it
Description
An object containing a prototyped trait attribute must contain a second attribute that references the object containing the prototype trait attribute. The name of this second attribute is passed as the prototype argument to the PrototypedFrom() function.
The following rules govern the application of the prefix parameter:
- If prefix is empty or omitted, the prototype delegation is to an attribute of the prototype object with the same name as the prototyped attribute.
- If prefix is a valid Python attribute name, then the prototype 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 prototype delegation is to an attribute whose name is the value of prefix, minus the trailing asterisk, prepended to the prototyped attribute name.
- If prefix is equal to a single asterisk, the prototype delegation is to an attribute whose name is the value of the prototype object's __prefix__ attribute prepended to the prototyped attribute name.
Note that any changes to the prototyped attribute are made to the original object, not the prototype object. The prototype object is only used to define to trait type and default value.