即使您不能从头开始创建并弹出本机工具提示,也可以在创建整个ListCtrl时为其分配工具提示,然后根据鼠标指针下的项目将文本更改为所需的内容。它不能像ObjectListView那样将工具提示整齐地放置在列表项上,但是我认为它仍然可以完成您所要的内容。
self.lc = wx.ListCtrl(self, style=wx.LC_REPORT) # ... self.lc.Bind(wx.EVT_MOTION, self.OnMouseMotion)def onMouseMotion(self, evt): pos = self.lc.ScreenToClient(wx.GetMousePosition()) item_index, flag = self.lc.HitTest(pos) tip = self.lc.GetToolTip() if flag == wx.LIST_HITTEST_ONITEMLABEL: tip.SetTip('Some information about ' + self.lc.GetItemText(item_index)) else: tip.SetTip('') evt.Skip()


