【发布时间】:2014-01-02 14:10:06
【问题描述】:
我有一个 wx.grid 表,当我将鼠标悬停在一个单元格上时,我想设置一个工具提示,我尝试了下面 Mike Driscoll 的建议,它有效,但我不能再用鼠标拖动选择多个单元格,它允许我最多只能选择 1 个单元格,请帮助:
self.grid_area.GetGridWindow().Bind(wx.EVT_MOTION, self.onMouseOver)
def onMouseOver(self, event):
'''
Method to calculate where the mouse is pointing and
then set the tooltip dynamically.
'''
# Use CalcUnscrolledPosition() to get the mouse position
# within the
# entire grid including what's offscreen
x, y = self.grid_area.CalcUnscrolledPosition(event.GetX(),event.GetY())
coords = self.grid_area.XYToCell(x, y)
# you only need these if you need the value in the cell
row = coords[0]
col = coords[1]
if self.grid_area.GetCellValue(row, col):
if self.grid_area.GetCellValue(row, col) == "ABC":
event.GetEventObject().SetToolTipString("Code is abc")
elif self.grid_area.GetCellValue(row, col) == "XYZ":
event.GetEventObject().SetToolTipString("code is xyz")
else:
event.GetEventObject().SetToolTipString("Unknown code")
【问题讨论】:
标签: grid wxpython tooltip mousehover