Inherits from
- BaseClass: enthought.traits.trait_types.BaseClass
Attributes
- adapt_default
adapt_default = 'no'
Inherited from base classes
Method summary
- __init__(self, klass = None, factory = None, args = None, kw = None, allow_none = True, adapt = None, module = None, **metadata)
- allow_none(self)
- create_default_value(self, *args, **kw)
- create_editor(self)
- get_default_value(self)
- info(self)
- init_fast_validate(self)
- resolve_class(self, object, name, value)
- validate(self, object, name, value)
Inherited from base classes
- __call__(self, *args, **kw)
- __getattr__(self, name)
- arg_error(self, method, arg_num, object, name, value)
- as_ctrait(self)
- clone(self, default_value = Missing, **metadata)
- dup_arg_error(self, method, arg_num, object, name)
- error(self, object, name, value)
- find_class(self, klass)
- full_info(self, object, name, value)
- get_editor(self, trait = None)
- get_value(self, object, name, trait = None)
- init(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)
- set_value(self, object, name, value)
- validate_class(self, klass)
- validate_failed(self, object, name, value)
Methods
- __init__(self, klass = None, factory = None, args = None, kw = None, allow_none = True, adapt = None, module = None, **metadata)
Returns an Instance trait.
Parameters
- klass : class or instance
- The object that forms the basis for the trait; if it is an instance, then trait values must be instances of the same class or a subclass. This object is not the default value, even if it is an instance.
- factory : callable
- A callable, typically a class, that when called with args and kw, returns the default value for the trait. If not specified, or None, klass is used as the factory.
- args : tuple
- Positional arguments for generating the default value.
- kw : dictionary
- Keyword arguments for generating the default value.
- allow_none : boolean
- Indicates whether None is allowed as a value.
- adapt : string
A string specifying how adaptation should be applied. The possible values are:
'no': Adaptation is not allowed.
- 'yes': Adaptation is allowed. If adaptation fails, an
exception should be raised.
- 'default': Adapation is allowed. If adaptation fails, the
default value for the trait should be used.
Default Value
None if klass is an instance or if it is a class and args and kw are not specified. Otherwise, the default value is the instance obtained by calling klass(*args, **kw). Note that the constructor call is performed each time a default value is assigned, so each default value assigned is a unique instance.
- allow_none(self)
- create_default_value(self, *args, **kw)
- create_editor(self)
Returns the default traits UI editor for this type of trait.
- get_default_value(self)
Returns a tuple of the form: ( default_value_type, default_value ) which describes the default value for this trait.
- info(self)
Returns a description of the trait.
- init_fast_validate(self)
Does nothing for the BaseInstance' class. Used by the 'Instance', 'AdaptedTo' and 'AdaptsTo' classes to set up the C-level fast validator.
- resolve_class(self, object, name, value)
- validate(self, object, name, value)
Validates that the value is a valid object instance.