943,584 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 2556
  • Python RSS
You are currently viewing page 1 of this multi-page discussion thread
May 28th, 2009
0

Tkinter set mouse position?

Expand Post »
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.)
Similar Threads
aot
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
aot is offline Offline
83 posts
since Feb 2007
May 29th, 2009
0

Re: Tkinter set mouse position?

You maybe want "focus" or "geometry" depending on what you mean by "mouse position". You can find examples for both of them here http://infohost.nmt.edu/tcc/help/pubs/tkinter/
Reputation Points: 741
Solved Threads: 691
Nearly a Posting Maven
woooee is offline Offline
2,302 posts
since Dec 2006
May 29th, 2009
0

Re: Tkinter set mouse position?

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
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
aot is offline Offline
83 posts
since Feb 2007
May 30th, 2009
0

Re: Tkinter set mouse position?

use mouseover or mousefocus at X,Y
Reputation Points: 10
Solved Threads: 1
Newbie Poster
sudhakar s is offline Offline
1 posts
since May 2009
May 30th, 2009
0

Re: Tkinter set mouse position?

Click to Expand / Collapse  Quote originally posted by sudhakar s ...
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)
Last edited by sneekula; May 30th, 2009 at 10:41 am.
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
Mar 17th, 2010
0
Re: Tkinter set mouse position?
Aot,

Did you find a solution?

regards
Reputation Points: 10
Solved Threads: 1
Newbie Poster
diego.sueiro is offline Offline
2 posts
since Mar 2010
Mar 18th, 2010
0
Re: Tkinter set mouse position?
Nope, never found a solution in Tkinter.
Last edited by aot; Mar 18th, 2010 at 6:24 am.
aot
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
aot is offline Offline
83 posts
since Feb 2007
Mar 19th, 2010
0
Re: Tkinter set mouse position?
I can't think of any practical use for this.
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Mar 19th, 2010
0
Re: Tkinter set mouse position?
Click to Expand / Collapse  Quote originally posted by vegaseat ...
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
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
aot is offline Offline
83 posts
since Feb 2007
Mar 19th, 2010
0
Re: Tkinter set mouse position?
You did not specify what OS you're coding in, but this one is to get the mouse position in Linux, and apparently in the same thread, Gribouillis gives an answer on how to do it in Windows as well. Also read vagaseat's post, which is interesting. Hope this helps.
Reputation Points: 18
Solved Threads: 9
Junior Poster
Dan08 is offline Offline
133 posts
since Jul 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Possible to get Tkinter and pygame to work together?
Next Thread in Python Forum Timeline: Working with a Tkinter Listbox (Python)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC