Friday, September 5, 2025
HomeLanguageswxPython – Show hidden toolbar in the frame

wxPython – Show hidden toolbar in the frame

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:

Parameter Input Type Description
show bool If 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: 

Python3




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 clicking button after clicking button

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32265 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS