Tkinter set mouse position?
I've realized that it would be very helpful to me to SET the mouse cursor to a particular location. Having done the usual internet searches, I can't seem to find anything on how to do it. Any ideas?
(So I'm still set on converting to wx, but the project I've just done in Tkinter needs to get finished ASAP. It's an experiment and we need to start running participants.)
aot
Junior Poster in Training
83 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
Hmm, I don't think I want either of those things. I want to be able to tell the program to move the mouse cursor to position x, y.
aot
Junior Poster in Training
83 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
use mouseover or mousefocus at X,Y
We are talking about the Tkinter GUI toolkit. There are no such methods.
widget.focus() puts the cursor to a widget
module turtle (uses tkinter) has a method goto(x,y)
sneekula
Nearly a Posting Maven
2,427 posts since Oct 2006
Reputation Points: 961
Solved Threads: 212
Nope, never found a solution in Tkinter.
aot
Junior Poster in Training
83 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
I can't think of any practical use for this.
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
I can't think of any practical use for this.
I'm a cognitive scientist; I use python to code experiments which often present stimuli to participants that they respond to. If I am timing their responses, sometimes I want very precise control over where the mouse cursor is.
In this particular case, I was making an experiment where participants would see two stimuli, one after another (say a circle and then a bigger circle), and then they would have to rate each on a vertical scale of radio buttons. Because I was timing them, I wanted the mouse cursor to always start in the middle of the scale, so I could time how long it took them to move the cursor from the middle to whichever button they chose.
Originally I just wanted the cursor to disappear during the stimuli presentation, but I couldn't find a way to do that, so I thought perhaps I could simply set the cursor to the center at the start of the radio-button rating.
In the end I just had to ask them not to move their cursor at all while the stimuli were on screen and coded it so that the screen would flash red at them if they did.
So, yeah. It has its uses. :-P
aot
Junior Poster in Training
83 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
Thanks! Although I've long since solved the problem for my particular study and hope to do future studies using wx. It still might come in handy.
aot
Junior Poster in Training
83 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
Ah yes. I'm sorry, it is about SETTING the mouse position. I read that last post too quickly I see.
aot
Junior Poster in Training
83 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
Thanks! Even if it requires Windows, I appreciate a solution.
aot
Junior Poster in Training
83 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
Tech B,
Is there a way to this in linux?
Regards
You should experiment with the method warp_pointer in the python-xlib module. (See also XWarpPointer in the xlib documentation). The problem is to find the good arguments to warp_pointer...
Gribouillis
Posting Maven
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691