Thursday, October 16, 2025
HomeLanguageswxPython – AddSimpleTool() function in wx.ToolBar

wxPython – AddSimpleTool() function in wx.ToolBar

In this article we are going to learn about another method in wx.ToolBar class of wxPython, that is, AddSimpleTool() method. AddSimpleTool() is old style method to add a tool to the toolbar.

Syntax:

wx.ToolBar.AddSimpleTool(self, id, bitmap, shortHelpString="", isToggle=0)

Parameters :

Parameter Input Type Description
toolid int An integer by which the tool may be identified in subsequent operations.
label string The string to be displayed with the tool.
bitmap wx.bitmap The primary tool bitmap.
bmpDisabled wx.bitmap The bitmap used when the tool is disabled.
kind int kind of toolbar.
shortHelp string This string is used for the tools tooltip.
longHelp string detailed string associated with tool.
clientData PyUserData An optional pointer to client data which can be retrieved later using GetToolClientData.

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):
        pnl = wx.Panel(self)
        self.toolbar = self.CreateToolBar()
 
        # Add Tool using AddSimpleTool() function
        ptool = self.toolbar.AddSimpleTool(12,  wx.Bitmap('/home/wxPython/right.png'),
                                                        shortHelpString ="Simple Tool")
        self.toolbar.Realize()
        self.SetSize((350, 250))
        self.SetTitle('Control')
        self.Centre()
         
 
 
def main():
 
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Output :

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

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS