Open In App

wxPython – SetToolShortHelp() 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 SetToolShortHelp() function associated with the wx.ToolBar class of wxPython. SetToolShortHelp() simply sets the short help for the given tool.
It takes two parameters that are, toolId and helpString(new short help string).

Syntax:

wx.ToolBar.SetToolShortHelp(self, toolId, helpString)

Parameters:

Parameter Input Type Description
toolId int ID of the tool in question, as passed to AddTool.
helpString string The string for the short help.

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, 'right', wx.Bitmap('right.png'))
        te = self.toolbar.AddTool(2, 'wrong', wx.Bitmap('wrong.png'))
  
        # set separation of toolbar to 20
        self.toolbar.SetToolShortHelp(toolId = 1, helpString ="new short help")
  
        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):
        print(self.toolbar.GetToolSeparation())
        # Realize() called to finalize new added tools
        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:



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads