wxPython wx.ToolBar中的GetToolShortHelp()函数
在这篇文章中,我们将学习与wxPython的wx.ToolBar类有关的GetToolShortHelp()函数。GetShortHelp()函数返回与一个特定工具相关的简短帮助字符串。我只接受toolId作为一个参数。
语法
wx.ToolBar.GetToolShortHelp(self, toolId)
参数:
参数 | 输入类型 | 描述 |
---|---|---|
toolId | int | 工具栏中工具的标识符。 |
返回类型。
string
代码实例1。
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):
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
pnl = wx.Panel(self)
self.toolbar = self.CreateToolBar()
# Add Tools Using AddTool function
rtool = self.toolbar.AddLabelTool(13, 'oneTool', wx.Bitmap('wrong.png'), shortHelp ="short help string one")
stool = self.toolbar.AddLabelTool(14, 'twoTool', wx.Bitmap('user.png'), shortHelp ="short help string two")
self.toolbar.Realize()
self.SetSize((350, 250))
self.SetTitle('Control')
self.Centre()
str = self.toolbar.GetToolShortHelp(13)
# print wx.ToolBarToolBase object o tool
print(str)
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
输出:
short help string one
代码实例1。
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):
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
pnl = wx.Panel(self)
self.toolbar = self.CreateToolBar()
# Add Tools Using AddTool function
rtool = self.toolbar.AddLabelTool(13, 'oneTool', wx.Bitmap('wrong.png'), shortHelp ="short help string one")
stool = self.toolbar.AddLabelTool(14, 'twoTool', wx.Bitmap('user.png'), shortHelp ="short help string two")
self.toolbar.Realize()
self.SetSize((350, 250))
self.SetTitle('Control')
self.Centre()
str = self.toolbar.GetToolShortHelp(13)+" "+self.toolbar.GetToolShortHelp(14)
# print short help string
print(str)
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
输出:
short help string one short help string two