我刚从TraitsUI开始,我是Python程序员的初学者。希望这个问题不要太低级。你知道吗
我想在控制面板上显示一个按钮,从Main调用它。当我做下面的操作时,我只看到一个窗口,上面有一个按钮,上面写着“Panel”。如果我点击那个按钮,我会得到另一个窗口,上面有我想要的“开始”按钮。我怎么用“开始”按钮打开窗口?你知道吗
谢谢你, 宇宙
主要内容: 你知道吗
from enthought.traits.api import *
from enthought.traits.ui.api import *
class ControlPanel(HasTraits):
""" This object is the core of the traitsUI interface. It hosts the method for
interaction between the objects and the GUI.
"""
start = Button("Start Measurements")
view = View(Item('start', show_label=False, style='custom' ))
class MainWindow(HasTraits):
""" The main window, here go the instructions to create and destroy the application. """
panel = Instance(ControlPanel)
def _panel_default(self):
return ControlPanel()
view = View(Item('panel'))
if __name__ == '__main__':
MainWindow().configure_traits()
在
MainWindow
中,更改以下内容:对此:
有关详细信息,请参阅InstanceEditor()文档。该文件的相关部分是屏幕截图下面的段落。
InstanceEditor
的simple
样式(这是默认样式)创建一个按钮,单击该按钮将打开一个包含实例视图的新窗口。custom
样式将实例的视图嵌入到包含该项的同一窗口中。图36中的屏幕截图示出了一个示例。屏幕截图的顶部显示了simple
样式,下面是custom
样式。(下面是text
和readonly
样式,但是除了调试之外,它们不是很有用。)相关问题 更多 >
编程相关推荐