开发者

wx.ListCtrl and column header tooltips

I'm looking for a way to show tooltips whenever the user hov开发者_运维问答ers the mouse on a column header of a wx.ListCtrl, is this possible?

I tried binding wx.EVT_MOTION but it looks like it works only for the list items, not the headers.. Am I doing something wrong?

Thanks in advance!

(wxPython 2.8.9.1 on Xubuntu 9.04)


I don't think this is possible at the present moment, the EVT_MOTION only picks up coords via GetPosition() when you are within the list itself, the columns do not appear to register a coord when you hover over them.

I was able to find this link where it appears they are working on such ability in wx.lib.agw.UltimateListCtrl, you might want to ask on the wxpython mailing list to see if/when this feature might be released.


I couldn't find a way to do this for column headers, but this works for individual cells:

    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()

It doesn't dispatch the event when I hover over column headers, at least not on my PC (Win 10).

I found this answer here: https://coderedirect.com/questions/378870/how-to-tweak-my-tooltips-in-wxpython.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜