1

有没有办法为一个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只是为了说明我希望它如何工作。

4

1 回答 1

2

是的,你几乎明白了。请参阅 http://code.enthought.com/projects/traits/docs/html/TUIUG/advanced_view.html#defining-multiple-views-within-the-model

于 2013-10-29T20:59:43.753 回答