wxPython GetLabelText() function in wxPython (original) (raw)
Last Updated : 09 Jun, 2020
In this article we are going to learn about GetLabelText() function associated with wx.MenuItem class of wxPython. GetLabelText() function strips all accelerator characters and mnemonics from the given text.
For Example:
wx.MenuItem.GetLabelfromText(“&Hello\tCtrl-h”)
will return just “Hello” .
Takes sing unstriped text as a parameter.
Syntax:
wx.MenuItem.GetLabelText()
Parameters:
text type: string description: unstriped text to get striped text.
Return Type:
string
Code Example:
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
.menubar
=
wx.MenuBar()
`` self
.fileMenu
=
wx.Menu()
`` self
.st
=
wx.StaticText(
self
, label
=
"", pos
=
(
20
,
20
), style
=
wx.ALIGN_LEFT)
`` self
.item
=
wx.MenuItem(
self
.fileMenu,
1
,
'&Check\tCtrl + c'
, helpString
=
"Check Help"
)
`` self
.item.SetBitmap(wx.Bitmap(
'right.png'
))
`` self
.fileMenu.Append(
self
.item)
`` self
.menubar.Append(
self
.fileMenu,
'&File'
)
`` self
.SetMenuBar(
self
.menubar)
`` label
=
self
.item.GetLabelText(
'&Check\tCtrl + c'
)
`` print
(label)
`` self
.st.SetLabel(label)
`` self
.SetSize((
350
,
250
))
`` self
.SetTitle(
'Icons and shortcuts'
)
`` self
.Centre()
def
main():
`` app
=
wx.App()
`` ex
=
Example(
None
)
`` ex.Show()
`` app.MainLoop()
if
__name__
=
=
'__main__'
:
`` main()
Output:
Check
Output Window:
Similar Reads
- wxPython | GetToolEnabled() function in python In this article we are going to learn about GetToolEnabled() function present in class wx.ToolBar of wxPython. GetToolEnabled() function simply returns a pointer to the tool at particular position. It takes only single argument that is pos(position of tool starting from 0). Syntax : wx.ToolBar.GetTo 2 min read
- wxPython - GetBatteryState() function in wxPython In this article we are going to learn about wx.GetBatteryState() which is a inbuilt parent function present in wxPython. GetBatteryState() returns battery state as one of BATTERY_NORMAL_STATE, BATTERY_LOW_STATE, BATTERY_CRITICAL_STATE, BATTERY_SHUTDOWN_STATE or BATTERY_UNKNOWN_STATE . BATTERY_UNKNOW 1 min read
- Python - GetMenu() function in wxPython In this particular article we are going to learn about GetMenu() function of wx.MenuBar class of wxPython. GetMenu() is function in wx.MenuBar class that return wx.Menu object present in Menubar. It needs only index of menu present on menubar. Syntax : wx.MenuBar.GetMenu(self, menuindex) Parameters 1 min read
- wxPython | GetToolPos() function in python In this article we are going to learn about GetToolPos() function associated with wx.ToolBar class of wxPython. GetToolPos() function simply returns the tool position in the toolbar, or NOT_FOUND if the tool is not found. GetToolPos() function only takes toolId(ID of the tool in question, as passed 2 min read
- wxPython | GetToolByPos() function in python In this article we are going to learn about GetToolByPos() function present in wx.ToolBar class of wxPython. GetToolByPos() function is used to simply return a pointer to the tool at specific position. GetToolByPos() function takes a single parameter that is pos(position of tool). Syntax: wx.ToolBar 2 min read
- wxPython | GetMargins() function in python In this article we are going to learn about GetMargins() function of class wx.ToolBar in wxPython. GetMargins() function returns the left/right and top/bottom margins, which are also used for inter-toolspacing. GetMargins takes no parameters. Syntax: wx.ToolBar.GetMargins(self) Parameters: No Parame 2 min read
- wxPython - GetMenuLabelText() function in wx.MenuBar GetMenuTextLabel() is alternative for GetMenuLabel() function. Just like GetMenuLabel() function GeteMenuTextLabel() function is used to return label of Menu present in Menubar. GetMenuTextLabel() only takes position of menu in the menubar. Syntax : wx.MenuBar.GetMenuLabelText(self, menuindex) Param 1 min read
- wxPython | GetToolBitmapSize() function in python In this article we are going to learn about GetToolBitmapSize() function of wxPython. GetToolBitmapSize() returns the size of bitmap that a toolbar expects to have. The default bitmap size is platform-dependent: for example, it is 16x15 for MSW and 24x24 for GTK. This size does not necessarily indic 2 min read
- wxPython - GetLabel() function in wx.Button In this article, we are going to learn about GetLabel() function associated with wx.Button class of wxPython. GetLabel() function is used to return the string label for the button. No parameters are required by GetLabel() function. Syntax: wx.Button.GetLabel(self) Parameters: No parameters are requi 1 min read
- wxPython - GetItemLabelText() function in wx.MenuItem In this article we are going to learn about GetItemLabelText() function associated with wx.MenuItem class of wxPython. GetItemLabelText() function is used to simply return the text associated with the menu item, without any accelerator characters. No parameters are required by GetItemLabelText() fun 1 min read