Open In App

wxPython – GetHelpString() function in wx.MenuBar

Last Updated : 09 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

As we learnt about SetHelpString(), in this article we will learn about GetHelpString() function in wx.MenuBar class of wxPython. SetHelpString() associates a helpstring with the menuitem, while GetHelpString() function returns the associated helpstring with the menu item.

Syntax :

wx.MenuBar.GetHelpString(id)

Parameters :

Parameter Input Type Description
id int Menu item identifier.

Returns : The help string, or the empty string, if there was no help string or the menu item, was not found.

Code Example : 

Python3




import wx
 
 
class Example(wx.Frame):
 
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
 
        self.InitUI()
 
 
    def InitUI(self):
        # create MenuBar using MenuBar() function
        menubar = wx.MenuBar()
 
        # add menu to MenuBar
        fm1 = wx.Menu()
        fileitem = fm1.Append(20, "Item # 1")
        menubar.Append(fm1, '&Menu # 1')
        self.SetMenuBar(menubar)
        self.SetSize((300, 200))
        self.SetTitle('Menu Bar')
        menubar.SetHelpString(20, "Help String")
 
        st = wx.StaticText(self, label ="click Item # 1 in Menu # 1")
 
 
        # get and print helpstring using GetHelpString() function
        print(menubar.GetHelpString(20))
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Output :

Help String


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads