简体   繁体   English

如何在工具栏中隐藏元素? wxPython的

[英]How to hide an element in a toolbar? wxpython

is it possible to hide (and later show) an element in a toolbar? 是否可以隐藏(以及稍后显示)工具栏中的元素?

    toolbar = self.CreateToolBar()
    element = toolbar.AddLabelTool(wx.ID_ANY, 'Hi', wx.Bitmap('hello.png'))
    toolbar.Realize()

Using element.Hide() returns an error, 使用element.Hide()返回错误,

Thanks for any support 谢谢你的支持

I don't think the wx.Toolbar supports hiding individual items. 我不认为wx.Toolbar支持隐藏单个项目。 However, the FlatMenu seems to: http://www.wxpython.org/docs/api/wx.lib.agw.flatmenu-module.html I would recommend giving that a try. 但是,FlatMenu似乎: http ://www.wxpython.org/docs/api/wx.lib.agw.flatmenu-module.html我建议尝试一下。

You can disable tool: 你可以禁用工具:

toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
toolbar.AddSimpleTool(1, wx.Image('stock_new.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '')
toolbar.EnableTool(1,False)

or you can just insert tool when you want to do this 或者你可以在你想要的时候插入工具

Tools can be removed from the tool bar. 可以从工具栏中删除工具。 They can then be added back later. 然后可以稍后添加它们。 Unfortunately, there is no simple hide function that I can find. 不幸的是,我找不到简单的隐藏功能。

https://wxpython.org/Phoenix/docs/html/wx.ToolBar.html#wx.ToolBar.RemoveTool https://wxpython.org/Phoenix/docs/html/wx.ToolBar.html#wx.ToolBar.RemoveTool

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM