问题
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!
回答1:
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)
来源:https://stackoverflow.com/questions/19566477/adding-nested-hastraits-properties-to-a-traitsui-tview