determine the absolute position of a cell

Many
people know that to determine the absolute position (relative to the
screen) of a window using the method getscreenposition. Unfortunately, this method can not be used to determine the precise location of grid’s cell.

I need to know the cell’s location because I load a frame the time of creation of CreateCellEditor.

there is some other solution to getscreenposition?

···


Fabio Spadaro
www.fabiospadaro.com

Hi Fabio,

Many people know that to determine the absolute position (relative to the
screen) of a window using the method getscreenposition. Unfortunately, this
method can not be used to determine the precise location of grid's cell.
I need to know the cell's location because I load a frame the time of
creation of CreateCellEditor.
there is some other solution to getscreenposition?

--
Fabio Spadaro

What you probably want to do it this:

1) Bind your grid to EVT_MOTION like this:

self.MyGrid.GetGridColLabelWindow().Bind(wx.EVT_MOTION,
self.onMouseOver)

2) In the event handler, grab the mouse position using something like
this:

pos = event.GetX()

3) Use that information to know where to put your frame.

···

On Dec 15, 4:05 pm, Fabio Spadaro <fabiolinos...@gmail.com> wrote:

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Hi,

···

2009/12/16 Mike Driscoll <kyosohma@gmail.com>

Hi Fabio,

On Dec 15, 4:05 pm, Fabio Spadaro <fabiolinos...@gmail.com> wrote:
> Many people know that to determine the absolute position (relative to the
> screen) of a window using the method getscreenposition. Unfortunately, this
> method can not be used to determine the precise location of grid's cell.
> I need to know the cell's location because I load a frame the time of
> creation of CreateCellEditor.
> there is some other solution to getscreenposition?
>
> --
> Fabio Spadaro

What you probably want to do it this:

1) Bind your grid to EVT_MOTION like this:

self.MyGrid.GetGridColLabelWindow().Bind(wx.EVT_MOTION,
self.onMouseOver)

2) In the event handler, grab the mouse position using something like
this:

pos = event.GetX()

3) Use that information to know where to put your frame.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

But the mouse event is not the only possible event as you may also use
the key event ...

--
Fabio Spadaro
www.fabiospadaro.com

Hi,

Hi,

> Hi Fabio,

> > Many people know that to determine the absolute position (relative to the
> > screen) of a window using the method getscreenposition. Unfortunately, this
> > method can not be used to determine the precise location of grid's cell.
> > I need to know the cell's location because I load a frame the time of
> > creation of CreateCellEditor.
> > there is some other solution to getscreenposition?

> > --
> > Fabio Spadaro

> What you probably want to do it this:

> 1) Bind your grid to EVT_MOTION like this:

> self.MyGrid.GetGridColLabelWindow().Bind(wx.EVT_MOTION,
> self.onMouseOver)

> 2) In the event handler, grab the mouse position using something like
> this:

> pos = event.GetX()

> 3) Use that information to know where to put your frame.

> -------------------
> Mike Driscoll

> Blog: http://blog.pythonlibrary.org

> --
> To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
> or visithttp://groups.google.com/group/wxPython-users?hl=en

But the mouse event is not the only possible event as you may also use
the key event ...

--
Fabio Spadaro

Well, you could bind to this instead:

self.myGrid.Bind(gridlib.EVT_GRID_EDITOR_CREATED, self.onCellEdit)

Then in the handler, get a handle on the control:

editor = event.GetControl()

and maybe this will work:

editor.GetScreenPosition()

I'm not sure though.

···

On Dec 16, 9:56 am, Fabio Spadaro <fabiolinos...@gmail.com> wrote:

2009/12/16 Mike Driscoll <kyoso...@gmail.com>
> On Dec 15, 4:05 pm, Fabio Spadaro <fabiolinos...@gmail.com> wrote:

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Something like this should do it:

  r = theGrid.CellToRect(row, col)
  screenPos = theGrid.GetGridWindow().ClientToScreen(r.position)

···

On 12/15/09 2:05 PM, Fabio Spadaro wrote:

Many people know that to determine the absolute position (relative to
the screen) of a window using the method getscreenposition.
Unfortunately, this method can not be used to determine the precise
location of grid's cell.
I need to know the cell's location because I load a frame the time of
creation of CreateCellEditor.
there is some other solution to getscreenposition?

--
Robin Dunn
Software Craftsman

Hi

···

2009/12/16 Robin Dunn <robin@alldunn.com>:

On 12/15/09 2:05 PM, Fabio Spadaro wrote:

Many people know that to determine the absolute position (relative to
the screen) of a window using the method getscreenposition.
Unfortunately, this method can not be used to determine the precise
location of grid's cell.
I need to know the cell's location because I load a frame the time of
creation of CreateCellEditor.
there is some other solution to getscreenposition?

Something like this should do it:

   r = theGrid\.CellToRect\(row, col\)
   screenPos = theGrid\.GetGridWindow\(\)\.ClientToScreen\(r\.position\)

--
Robin Dunn
Software Craftsman
http://wxPython.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

ok your solution does work but How do I calculate the displacement of
scrolled coordinates ?

--
Fabio Spadaro
www.fabiospadaro.com