Enables any Python class derived from it to have trait atttributes.

Most of the methods of HasTraits operated by default only on the trait attributes explicitly defined in the class definition. They do not operate on trait attributes defined by way of wildcards or by calling add_trait(). For example:

>>>class Person(HasTraits):
...    name = Str
...    age  = Int
...    temp_ = Any
>>>bob = Person()
>>>bob.temp_lunch = 'sandwich'
>>>bob.add_trait('favorite_sport', Str('football'))
>>>print bob.trait_names()
['trait_added', 'age', 'name']

In this example, the trait_names() method returns only the age and name attributes defined on the Person class. (The trait_added attribute is an explicit trait event defined on the HasTraits class.) The wildcard attribute temp_lunch and the dynamically-added trait attribute favorite_sport are not listed.

Inherits from

Attributes

Method summary

Methods