如何使用代码在python中删除Mayavi工具栏 [英] How to remove Mayavi toolbar in python using code
问题描述
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屋!