有没有办法为一个HasTraits
对象定义多个视图,并在将它们显示为时选择它们Item
?
class Person(HasTraits):
first_name = String()
last_name = String()
formal_view = View(
Item('first_name'),
Item('last_name'),
)
familiar_view = View(
Item('first_name')
)
class Family(HasTraits):
formal_father = Instance(Person,())
familiar_father = Instance(Person,())
view = View(
Item('formal_father', style = 'custom'),
Item('familiar_father', style = 'custom',
view = 'familiar_view'),
)
最后一项中的关键字view
只是为了说明我希望它如何工作。