By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

wxPython Grid XY Coordinates question

P: n/a
Hello All,
I am writing an app in wxPython using a grid. I need to be able to
recognize what cell in the grid the user is hovering over with the
mouse. How to do this?
I tried XYToCell(x, y), but that doesnt work properly because it
thinks that mouse position (0, 0) is the first cell in the grid, and
then goes from there, so if i move the grid to a differernt area on the
screen, the XYToCell is messed up in what it returns.

Any ideas on how to get this to work or any other way?

thanks,
Kiran

Jul 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Kiran wrote:
Hello All,
I am writing an app in wxPython using a grid. I need to be able to
recognize what cell in the grid the user is hovering over with the
mouse. How to do this?
I tried XYToCell(x, y), but that doesnt work properly because it
thinks that mouse position (0, 0) is the first cell in the grid, and
then goes from there, so if i move the grid to a differernt area on the
screen, the XYToCell is messed up in what it returns.

Any ideas on how to get this to work or any other way?
XYToCell probably takes window (client) coordinates. If you have the
mouse position in screen coordinates, you will need to convert them with
the ScreenToClient for your grid.

Will McGugan
--
work: http://www.kelpiesoft.com
blog: http://www.willmcgugan.com
Jul 14 '06 #2

P: n/a
Will, thank you.
That was the right thing to do, and it worked

-- Kiran

Will McGugan wrote:
Kiran wrote:
Hello All,
I am writing an app in wxPython using a grid. I need to be able to
recognize what cell in the grid the user is hovering over with the
mouse. How to do this?
I tried XYToCell(x, y), but that doesnt work properly because it
thinks that mouse position (0, 0) is the first cell in the grid, and
then goes from there, so if i move the grid to a differernt area on the
screen, the XYToCell is messed up in what it returns.

Any ideas on how to get this to work or any other way?

XYToCell probably takes window (client) coordinates. If you have the
mouse position in screen coordinates, you will need to convert them with
the ScreenToClient for your grid.

Will McGugan
--
work: http://www.kelpiesoft.com
blog: http://www.willmcgugan.com
Jul 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.