Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

wxPython – Hide toolbar from frame

  • Last Updated : 26 Jun, 2020

In this article we are going to learn that how can we hide toolbar present in the frame. In order to do that we will be using Hide() function. Hide() function simply hides the Toolbar window and not delete it like Drop() function. Hidden toolbar can be shown again using Show() function.

Syntax: wx.ToolBar.Hide(Self)

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Parameters: No parameters required by Hide() function.

Return Type: bool

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
        self.btn = wx.Button(self, label ='Hide Toolbar', pos =(20, 20))
  
        # bind event with button
        self.btn.Bind(wx.EVT_BUTTON, self.onclick)
  
  
        self.SetSize((350, 250))
        self.SetTitle('Simple toolbar')
        self.Centre()
  
    def onclick(self, e):
        # hide toolbar
        self.toolbar.Hide()
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

Output Window:

before clicking button


after clicking button




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!