问题描述
我有一个 main HasTraits类,其中包含其他多个HasTraits对象的实例.我想在main
对象的视图中定义一个Item,该对象指向嵌套对象的特征.例如:
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'),
)
这可能吗?
谢谢!
推荐答案
一个叫Alex的人在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'),
)
请参见 http://docs.enthought的底部. com/traitsui/traitsui_user_manual/advanced_view.html#multi-object-views
如果您是同一位Alex,则可能需要调整垃圾邮件过滤器(enthought.com和enthought.zendesk.com)
If you are the same Alex, you might want to tweak your spam filters (enthought.com and enthought.zendesk.com)
这篇关于将嵌套的HasTraits属性添加到TraitsUI TView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!