apptools.naming.trait_defs.naming_traits module

class apptools.naming.trait_defs.naming_traits.NamingTraitHandler(aClass, or_none, module)[source]

Bases: traits.trait_handler.TraitHandler

find_class()[source]
get_editor(trait)[source]

Returns a trait editor that allows the user to modify the trait trait. This method only needs to be specified if traits defined using this trait handler require a non-default trait editor in trait user interfaces. The default implementation of this method returns a trait editor that allows the user to type an arbitrary string as the value.

For more information on trait user interfaces, refer to the Traits UI User Guide.

Parameters

trait (Trait) – The trait to be edited.

info()[source]

Must return a string describing the type of value accepted by the trait handler.

The string should be a phrase describing the type defined by the TraitHandler subclass, rather than a complete sentence. For example, use the phrase, “a square sprocket” instead of the sentence, “The value must be a square sprocket.” The value returned by info() is combined with other information whenever an error occurs and therefore makes more sense to the user if the result is a phrase. The info() method is similar in purpose and use to the info attribute of a validator function.

Note that the result can include information specific to the particular trait handler instance. If the info() method is not overridden, the default method returns the value of the ‘info_text’ attribute.

post_setattr(object, name, value)[source]
resolve_class(object, name, value)[source]
validate(object, name, value)[source]

Verifies whether a new value assigned to a trait attribute is valid.

This method must be implemented by subclasses of TraitHandler. It is called whenever a new value is assigned to a trait attribute defined using this trait handler.

If the value received by validate() is not valid for the trait attribute, the method must called the predefined error() method to raise a TraitError exception

Parameters
  • object (HasTraits instance) – The object whose attribute is being assigned.

  • name (str) – The name of the attribute being assigned.

  • value (any) – The proposed new value for the attribute.

Returns

If the new value is valid, this method must return either the original value passed to it, or an alternate value to be assigned in place of the original value. Whatever value this method returns is the actual value assigned to object.name.

Return type

any

validate_failed(object, name, value)[source]