[wxPython-users] Capturing mouse position in wx.Grid
Mike Driscoll
mdriscoll at co.marshall.ia.us
Tue Mar 4 12:29:14 PST 2008
Robin et al,
> -----Original Message-----
> From: Robin Dunn [mailto:robin at alldunn.com]
> Sent: Friday, February 29, 2008 4:57 PM
> To: wxPython-users at lists.wxwidgets.org
> Subject: Re: [wxPython-users] Capturing mouse position in wx.Grid
>
> Mike Driscoll wrote:
>
> > In my handler, I was using GetPosition(), but that always
> returns the
> > same tuple no matter where I move the mouse.
>
> The mouse event's GetPosition()? Strange, that should be working...
> Can you make a small sample?
>
> > Right now, what I want is to be
> > able to mouse over any cell in a certain column and grab
> that cell's
> > contents and multiply it by a value which is then displayed in the
> > tooltip.
> >
> > I'm sure there's a way to get the mouse position and
> translate it into
> > a (row, col) tuple, but I just don't see how to do it at the moment.
>
> coords = grid.XTToCell(x, y)
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org Java give you jitters? Relax with wxPython!
>
>
It looks like these XYToCell, YToRow, and XToCol methods don't work quite
the way I need. My grid actually has scroll bars that go to the right and
left as well as up and down (I didn't think to mention this earlier;
sorry!). All of these methods only calculate on what is currently shown
onscreen, which breaks their functionality for my purposes anyway. For
example, if I need the cell value in (0,0) and I've scrolled 3 columns to
the right, then I end up with (0,3)'s value instead.
Also, when I tried to set the tooltip string for the cell I was mousing
over by doing the following:
event.GetEventObject().SetToolTipString('My message')
it didn't always update when I'd move to another cell and instead,
retained the previous value of the tooltip. Does anyone know how to fix
either of these issues?
Mike
More information about the wxpython-users
mailing list