Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

wxPython | InsertSimpleTool() function in python

  • Last Updated : 19 Aug, 2021

In this article we are going to learn about InsertSimpleTool() function associated with wx.ToolBar class of wxPython. InsertSimpleTool() function is another old style method to insert a tool in the toolbar. InsertSimpleTool() function inserts the tool with the specified attributes into the toolbar at the given position.


 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

wx.ToolBar.InsertSimplTool(self, pos, toolId, bitmap, shortHelpString="", longHelpString="", isToggle=0)


ParameterInput TypeDescription
posintPosition of tool to be added starting from 0.
toolidintAn integer by which the tool may be identified in subsequent operations.
bitmapwx.bitmapThe primary tool bitmap.
shortHelpStringstringThis string is used for the tools tooltip.
longHelpStringstringdetailed string associated with tool.
isToggleint0 for normal 1 for toggle button.

Return Type: 



Code Example 1:


import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.toolbar = self.CreateToolBar()
        td = self.toolbar.AddTool(1, '', wx.Bitmap('user.png'))
        self.Bind(wx.EVT_TOOL, self.OnOne, td)
        self.SetSize((350, 250))
        self.SetTitle('Undo redo')
    def OnOne(self, e):
        # insert tool at position 1
        self.toolbar.InsertSimpleTool(pos = 1, toolId = 2, bitmap = wx.Bitmap('right.png'), shortHelpString ="new tool one", isToggle = 0)
        # insert tool at position 2
        self.toolbar.InsertSimpleTool(pos = 2, toolId = 3, bitmap = wx.Bitmap('wrong.png'), shortHelpString ="new tool two", isToggle = 0)
    def OnQuit(self, e):
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output : 
before clicking profile icon: 

after clicking profile icon: 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!