set mouse position

114 views
Skip to first unread message

Marius

unread,
Nov 18, 2018, 9:09:57 PM11/18/18
to vispy
Hi,

I am a beginner with VisPy (and in many other aspects of PC programming :) )

In my app VisPy is used with PyQt and I can do something like:
cursor=QtGui.QCursor()
cursor
.setPos(x,y)
but by doing this, as expected, the mouse pointer is moved to x, y coordinates of the monitor screen having the origin in the top left corner.

I know that you can get the mouse position in the central widget by using:
event.pos

Is there a way to set the mouse position to a certain location in the central widget? 
A sort of setPos() but for coordinates inside central widget of VIsPy?

I am trying to move the mouse pointer programmatically to a certain position within central widget.

Thank you!

David Hoese

unread,
Nov 19, 2018, 9:15:01 AM11/19/18
to vispy
I'm not sure this is specific to vispy. You should be able to google ways to do this with Qt/PyQt (sorry I don't know the answer off the top of my head). You should be able to programmatically determine the position of your Qt Window and/or the VisPy Canvas widget (`canvas.native`). There seem to be a lot of position methods (pos, mapFrom, mapFromParent, etc) that may be able to help. If you need to map to a specific canvas (vispy) coordinate then you can look in to the `transforms` attribute that is on the canvas and visuals. This should help you convert any canvas pixel position to any other coordinate system you have within your vispy canvas.

Hopefully that helps a little.

Dave

Marius

unread,
Nov 19, 2018, 11:24:08 AM11/19/18
to vispy
Hi Dave,

Thanks for the hints, I will read about this. In the end if I find a way to get the screen coordinates of the canvas widget origin for the current window position on the screen then my issue is solved.

Thanks,
Marius
Reply all
Reply to author
Forward
0 new messages