问题
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?
回答1:
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())
The windows shows as:

来源:https://stackoverflow.com/questions/15444458/how-to-remove-mayavi-toolbar-in-python-using-code