如何使用代码在python中删除Mayavi工具栏

如何使用代码在python中删除Mayavi工具栏

本文介绍了如何使用代码在python中删除Mayavi工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个Mayavi图在一个窗口中合并(沿着文档),如果我可以摆脱所有工具栏中的工具栏,那就更好了.虽然可以右键单击每个工具栏使它们消失,但是我想对它们进行编码.像scene.hide_toolbar()这样的命令将是理想的.我已经在TraitsUI包中挖了一下,但无济于事……有人知道如何使其消失吗?

I have several Mayavi plots that I am combining in a single window (along the lines of the documentation), and it would be much better if I could get rid of the toolbars in all of them. While it's possible to to right-click each of the toolbars to have them disappear, I would like to code them to disappear instead. A command like scene.hide_toolbar() would be ideal. I've dug around in the TraitsUI package a bit to no avail... anybody know how to make it go away?

推荐答案

您可以使用Handler来修改UI,以下代码与ETS_TOOLKIT = qt4一起使用.将DisableToolbarHandler类添加到代码multiple_mlab_scene_models.py中,并通过m.edit_traits(handler=DisableToolbarHandler())显示UI.

You can use Handler to modify UI, the following code works with ETS_TOOLKIT=qt4. Add the DisableToolbarHandler class to the code multiple_mlab_scene_models.py, and show the UI by m.edit_traits(handler=DisableToolbarHandler()).

class DisableToolbarHandler(Handler):
    def position(self, info):
        for name in ["scene1", "scene2"]:
            editor = info.ui.get_editors(name)[0]
            editor._scene._tool_bar.setVisible(False)

m = MyDialog()
m.edit_traits(handler=DisableToolbarHandler())

窗口显示为:

这篇关于如何使用代码在python中删除Mayavi工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:58