Open In App

wxPython | InsertLabelTool() function in wx.ToolBar

Last Updated : 04 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we are going to learn about InsertLabelTool() function associated with class wx.ToolBar in wxPython. InsertLabelTool() is an old style method to insert a tool in the toolbar. InsertLabelTool() takes different property of tool as parameters to insert tool.

Syntax :

wx.ToolBar.InsertLabelTool(self, pos, id, label, bitmap, bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL, shortHelp="", longHelp="", clientData=None)

Parameters :

Parameter Input Type Description
pos int position on which tool is to be added starting from 0.
id 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.

Return Type:

wx.ToolBarToolBase

Code Example 1:




import wx
  
class Example(wx.Frame):
  
    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()
        td = self.toolbar.AddTool(1, '', wx.Bitmap('user.png'))
  
        self.toolbar.Realize()
        self.Bind(wx.EVT_TOOL, self.OnOne, td)
  
        self.SetSize((350, 250))
        self.SetTitle('Undo redo')
        self.Centre()
  
    def OnOne(self, e):
        # insert tool at position 1
        self.toolbar.InsertLabelTool( pos = 1, id = 3, label ='new tool1', bitmap = wx.Bitmap('right.png'), kind = wx.ITEM_NORMAL, shortHelp ="nono")
        self.toolbar.Realize()
  
    def OnQuit(self, e):
        self.Close()
  
  
def main():
  
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()


Output:
before clicking profile tool:

after clicking profile tool:



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads