Open In App

wxPython - AddSimpleTool() function in wx.ToolBar

Last Updated : 03 Mar, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

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 :

ParameterInput TypeDescription
toolidintAn integer by which the tool may be identified in subsequent operations.
labelstringThe string to be displayed with the tool.
bitmapwx.bitmapThe primary tool bitmap.
bmpDisabledwx.bitmapThe bitmap used when the tool is disabled.
kindintkind of toolbar.
shortHelpstringThis string is used for the tools tooltip.
longHelpstringdetailed string associated with tool.
clientDataPyUserDataAn 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 :


Next Article
Article Tags :
Practice Tags :

Similar Reads