Skip to content
Related Articles

Related Articles

Python – Create multiple toolbars in wxPython
  • Last Updated : 15 May, 2020

As we created a single toolbar in our previous article we are now going to learn how can we create multiple toolbars in wxPython. So we are going to create two toolbars and add tools to both of them.

Steps :

1. Create a vertical sizer.
2. Create first toolbar.
3. Add tools to first toolbar.
2. Create second toolbar.
3. Add tools to second toolbar.
4. Associate toolbars with sizer.

Code Example :
create twoo toolbars

import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        vbox = wx.BoxSizer(wx.VERTICAL)
        toolbar1 = wx.ToolBar(self)
        toolbar1.AddTool(wx.ID_ANY, '', wx.Bitmap('/Desktop/wxPython/signs.png'))
        toolbar1.AddTool(wx.ID_ANY, '', wx.Bitmap('/Desktop/wxPython/login.png'))
        toolbar2 = wx.ToolBar(self)
        qtool = toolbar2.AddTool(wx.ID_EXIT, '', wx.Bitmap('/Desktop/wxPython/password.png'))
        vbox.Add(toolbar1, 0, wx.EXPAND)
        vbox.Add(toolbar2, 0, wx.EXPAND)
        self.Bind(wx.EVT_TOOL, self.OnQuit, qtool)
        self.SetSize((600, 4000))
        self.SetTitle('Multiple Toolbars')
    def OnQuit(self, e):
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output :

 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

My Personal Notes arrow_drop_up
Recommended Articles
Page :