Skip to content
Related Articles

Related Articles

wxPython – Show hidden toolbar in the frame

Improve Article
Save Article
Like Article
  • Last Updated : 26 Jun, 2020

In this article, we will learn how can we show a hidden Toolbar. In order to unhide/show a Toolbar we can use Show() function. Show() function can be used to do both shows as well as hide the Toolbar. Show() function takes show boolean parameter which, If True displays the window. Otherwise, hides it.

Syntax: wx.ToolBar.Show(self, show=True)

Parameters:

ParameterInput TypeDescription
showboolIf True displays the window. Otherwise, hides it.

Return Type: bool

Returns: True if the window has been shown or hidden or False if nothing was done because it already was in the requested state.

Code Example:




import wx
  
  
class Example(wx.Frame):
    global count
    count = 0;
  
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
  
        self.InitUI()
  
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.toolbar = self.CreateToolBar()
        tool = self.toolbar.AddTool(wx.ID_ANY, 'First'
                                  wx.Bitmap('right.png'))
        self.toolbar.Realize()
  
        # panel for button
        self.pnl = wx.Panel(self)
  
        # button to hide toolbar
        self.btn = wx.Button(self.pnl, label ='Hide Toolbar', pos =(20, 20))
  
        # button to show toolbar
        self.btn2 = wx.Button(self.pnl, label ='Show Toolbar', pos =(200, 20))
  
        # bind event with hide button
        self.btn.Bind(wx.EVT_BUTTON, self.onclickhide)
  
        # bind event with show button
        self.btn2.Bind(wx.EVT_BUTTON, self.onclickshow)
  
        self.SetSize((350, 250))
        self.SetTitle('Simple toolbar')
        self.Centre()
  
    def onclickhide(self, e):
        # hide toolbar
        self.toolbar.Hide()
  
    def onclickshow(self, e):
        # hide toolbar
        self.toolbar.Show(True)
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

Output Window:

before clickin button


after clicking button


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!