win32api.SetCursorPos() question

vincent wehren vincent at visualtrans.de
Sat Sep 18 18:07:15 CEST 2004


Gary Richardson wrote:
> I'm trying to use win32api.SetCursorPos() to position the cursor in a
> Tkinter canvas window. I.e.:
> 
> from Tkinter import *
> import win32api
> root = Tk()
> canvas = Canvas(root,  width=400, height=300, bg='white')
> canvas.pack()
> win32api.SetCursorPos(100,100)
> root.mainloop()
> 
> But this code produces:
> 
> Traceback (most recent call last):
>   File
> "C:\Python22\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
> line 301, in RunScript
>     exec codeObject in __main__.__dict__
>   File "C:\My Documents\Python\Ascii\Script4.py", line 6, in ?
>     win32api.SetCursorPos(100,100)
> TypeError: SetCursorPos() takes exactly 1 argument (2 given)
> 
> Am I using this function incorrectly? A search on Google didn't turn up much
> but I did find one bit of code in which it was used in this manner.
> 
> I suspect there may be other problems with this approach so any further
> comments will be appreciated also. I'm using ActivePython 2.2.2 build 224 on
> Win98SE.
> 

Different then what the docs say, this function seems to want a tuple as 
argument. See if win32api.SetCursorPos((100,100)) does the trick.

--
Vincent Wehren



> Thanks,
> Gary Richardson
> 
> 
> 
> 
> 
> 



More information about the Python-list mailing list