在本文中,我們將學習與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
相關用法
- wxPython GetToolByPos()用法及代碼示例
- wxPython wx.ToolBar GetToolState()用法及代碼示例
- wxPython wx.StaticText SetBackgroundColour()用法及代碼示例
- wxPython wx.StaticText SetForegroundColour()用法及代碼示例
- wxPython wx.StaticText GetLabel()用法及代碼示例
- wxPython GetClassDefaultAttributes()用法及代碼示例
- wxPython wx.ToolBar AddTool()用法及代碼示例
- wxPython FindToolForPosition()用法及代碼示例
- wxPython FindControl()用法及代碼示例
- wxPython GetToolBitmapSize()用法及代碼示例
注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 wxPython | GetToolShortHelp() function in wx.ToolBar。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。