私は現在、単一のオブジェクトの多くのインスタンスを含むクラスの traitsUI GUI を作成しようとしています。私の問題は、 MultiObjectView Example TraitsUIで解決された問題と非常によく似ています。
ただし、コンテキストを使用するという考えは好きではありません。コンテキストを使用すると、オブジェクトごとに同じビューを何度も書き出す必要があるためです (そして、多くのオブジェクトがある可能性があります)。そこで、コードを編集して、House オブジェクトから見たときに House オブジェクトの各インスタンスがデフォルトで通常のビューのように見えるようにしようとしました。1 つのウィンドウにネストされたビュー (上記の TraitsUI の例の出力のように) を表示するのではなく、必要なビューに移動するボタンを取得することを除いて、ほとんど機能しました。
目的の出力を得るために以下を適応させる方法はありますか? create_editor 関数をさらに編集する必要があると思いますが、これに関するドキュメントはほとんど見つかりません。さまざまな特性エディター ファクトリへのリンクがたくさんあるだけです...
ありがとう、
ティム
# multi_object_view.py -- Sample code to show multi-object view
# with context
from traits.api import HasTraits, Str, Int, Bool
from traitsui.api import View, Group, Item,InstanceEditor
# Sample class
class House(HasTraits):
address = Str
bedrooms = Int
pool = Bool
price = Int
traits_view =View(
Group(Item('address'), Item('bedrooms'), Item('pool'), Item('price'))
)
def create_editor(self):
""" Returns the default traits UI editor for this type of trait.
"""
return InstanceEditor(view='traits_view')
class Houses(HasTraits):
house1 = House()
house2= House()
house3 = House()
traits_view =View(
Group(Item('house1',editor = house1.create_editor()), Item('house2',editor = house1.create_editor()), Item('house3',editor = house1.create_editor()))
)
hs = Houses()
hs.configure_traits()