我正在尝试为功能区控件创建工具提示文本。我已经设置了help_strings,但不知道如何显示它们。即使它只是一个工具提示文本,因为wxpython显示按钮对我来说没问题。
我附上了代码示例(RibbobDemo.py的修改版本),我希望在mouseover上有help_strings。
我很欣赏代码示例或指向引用。
import wx
import wx.lib.agw.ribbon as RB
class RibbonFrame(wx.Frame):
def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self._ribbon = RB.RibbonBar(self, wx.ID_ANY)
home = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Examples", wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN))
toolbar_panel = RB.RibbonPanel(home, wx.ID_ANY, "Toolbar", wx.NullBitmap, wx.DefaultPosition,
wx.DefaultSize, RB.RIBBON_PANEL_NO_AUTO_MINIMISE)
toolbar = RB.RibbonToolBar(toolbar_panel, wx.ID_ANY)
# this is just a simple tool
toolbar.AddTool(wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN), help_string=" the first tool")
toolbar.AddTool(wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_ERROR), help_string=" the second tool")
toolbar.AddTool(wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_INFORMATION), help_string=" the third tool")
toolbar.AddSeparator()
self._ribbon.Realize()
self._logwindow = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize,
wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_LEFT | wx.TE_BESTWRAP | wx.BORDER_NONE)
s = wx.BoxSizer(wx.VERTICAL)
s.Add(self._ribbon, 0, wx.EXPAND)
s.Add(self._logwindow, 1, wx.EXPAND)
self.SetSizer(s)
if __name__ == "__main__":
app = wx.PySimpleApp()
frame = RibbonFrame(None, -1, "wxPython Ribbon Sample Application", size=(800, 600))
frame.CenterOnScreen()
frame.Show()
app.MainLoop()
答案 0 :(得分:0)
我从http://www.wxpython.org/download.php安装了 wxPython3.0文档和演示。在那里,在Advanced Generic Widgets下,我找到了Pure-Python RibbonBar的演示,它有一个工具提示文本显示。它显示为常用按钮工具提示。但是,我决定满足于此。我感谢所有参与编写文档和演示的人。这将非常有用!