wxPython – Hide toolbar from frame
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)
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
Please Login to comment...