如何使用代码在python中删除Mayavi工具栏 [英] How to remove Mayavi toolbar in python using code

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

问题描述

我有多个Mayavi图在一个窗口中合并(沿着

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工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆