科学计算三维可视化---TraitsUI(配置视图)

配置视图

模态窗口:

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()

 

 

posted @ 2018-07-14 17:06  山上有风景  阅读(629)  评论(0编辑  收藏  举报