thelost
thelost

Reputation: 705

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,

Thanks for any support

Upvotes: 1

Views: 1272

Answers (3)

Kade
Kade

Reputation: 1022

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

Upvotes: 0

Mike Driscoll
Mike Driscoll

Reputation: 33071

I don't think the wx.Toolbar supports hiding individual items. However, the FlatMenu seems to: http://www.wxpython.org/docs/api/wx.lib.agw.flatmenu-module.html I would recommend giving that a try.

Upvotes: 2

user1117550
user1117550

Reputation: 51

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

Upvotes: 1

Related Questions