Question

i have a main HasTraits class which contains several Instance's of other HasTraits objects. I would like to define an Item in the view of the main object which points to a trait of a nested object. for example:

class Person(HasTraits):
    name = String()

class Pet(HasTraits):
    name = String()


class Family(HasTraits):
    father = Instance(Person,())
    dog = Instance(Pet,())

    view = View(
        Item('father.name'),
        Item('dog.name'),
        )

is this possible?

thanks!

Was it helpful?

Solution

Somebody named Alex asked this question 1 week ago by email, and we responded:

view = View(
    Item('object.father.name'),
    Item('object.dog.name'),
    )

See the bottom of http://docs.enthought.com/traitsui/traitsui_user_manual/advanced_view.html#multi-object-views

If you are the same Alex, you might want to tweak your spam filters (enthought.com and enthought.zendesk.com)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top