配置视图




模态窗口:
from traits.api import HasTraits,Int,Strclass ModelManager(HasTraits):
model_name = Str
category = Str
model_number = Int
vertices = Int
model = ModelManager()
model.configure_traits()

非模态窗口:
from traits.api import HasTraits,Int,Str
class ModelManager(HasTraits):
model_name = Str
category = Str
model_number = Int
vertices = Int
model = ModelManager()
model.edit_traits()

模态和非模态比较

traitsUI按钮配置



from traits.api import HasTraits,Int,Str
from traitsui.api import View,Item,Group,ModalButtons
#View描述了界面的视图类,Item模块描述了界面中的控件类
class ModelManager(HasTraits):
model_name = Str
category = Str
model_file = Str
model_number = Int
vertices = Int
view1 = View(
Group(
Item("model_name", label=u"模型名称"),
Item("model_file", label=u"文件名"),
Item("category", label=u"模型类型"),
label=u"模型信息",
show_border=True
),
Group(
Item("model_number", label=u"模型数量"),
Item("vertices", label=u"顶点数量"),
label=u"统计数据",
show_border=True
),
kind = "modal",
buttons = ModalButtons
)
model = ModelManager()
model.configure_traits()
