traits

Instantiating a default instance for an Enthought trait

Instantiating a default instance for an Enthought trait Question: Consider this simple minimal example: from traits.api import Instance, Str, HasTraits class Person(HasTraits): name = Str(“hooked”) class Chair(HasTraits): sitting = Instance(Person) t = Chair() print t.sitting.name This fails since t.sitting evaluates to None. Enthought’s traits module will enforce that the type of t.sitting is a Person …

Total answers: 3

How can I fire a Traits static event notification on a List?

How can I fire a Traits static event notification on a List? Question: I am working through the traits presentation from PyCon 2010. At about 2:30:45 the presenter starts covering trait event notifications, which allow (among other things) the ability to automatically call a subroutine any time a trait has changed. I am running a …

Total answers: 2