wxPython GetToolLongHelp()函数与python的关系
在这篇文章中,我们将学习wxPython的wx.ToolBar类中的GetToolLongHelp()函数。GetToolLongHelp()函数返回给定工具的长帮助。它只需要一个参数,即toololid(有关工具的ID,如传递给AddTool)。
语法。
wx.GetToolLongHelp(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()
self.toolbar.SetMargins(10, 10)
# Add Tools Using AddTool function
rtool = self.toolbar.AddLabelTool(id = 13, label = "Tool one", bitmap = wx.Bitmap('wrong.png'), shortHelp ="short help 1", longHelp = "Long help associated with simple tool 1")
stool = self.toolbar.AddLabelTool(id = 14, label = "Tool two", bitmap = wx.Bitmap('wrong.png'), shortHelp ="short help 2", longHelp = "Long help associated with simple tool 2")
self.toolbar.Realize()
self.SetSize((350, 250))
self.SetTitle('Control')
self.Centre()
bl = self.toolbar.GetToolLongHelp(13)
# print tool longHelp string
print(bl)
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
输出。
Long help associated with simple tool 1
代码示例2。
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()
self.toolbar.SetMargins(10, 10)
# Add Tools Using AddTool function
rtool = self.toolbar.AddLabelTool(id = 13, label = "Tool one", bitmap = wx.Bitmap('wrong.png'), shortHelp ="short help 1", longHelp = "Long help associated with simple tool 1")
stool = self.toolbar.AddLabelTool(id = 14, label = "Tool two", bitmap = wx.Bitmap('wrong.png'), shortHelp ="short help 2", longHelp = "Long help associated with simple tool 2")
self.toolbar.Realize()
self.SetSize((350, 250))
self.SetTitle('Control')
self.Centre()
bl = self.toolbar.GetToolLongHelp(14)
# print tool longHelp string
print(bl)
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
输出。
Long help associated with simple tool 2