473,806 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

win32api.SetCur sorPos() question

I'm trying to use win32api.SetCur sorPos() 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.SetCur sorPos(100,100)
root.mainloop()

But this code produces:

Traceback (most recent call last):
File
"C:\Python22\Li b\site-packages\Python win\pywin\frame work\scriptutil s.py",
line 301, in RunScript
exec codeObject in __main__.__dict __
File "C:\My Documents\Pytho n\Ascii\Script4 .py", line 6, in ?
win32api.SetCur sorPos(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.

Thanks,
Gary Richardson


Jul 18 '05 #1
5 7451
Gary Richardson wrote:
I'm trying to use win32api.SetCur sorPos() 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.SetCur sorPos(100,100)
root.mainloop()

But this code produces:

Traceback (most recent call last):
File
"C:\Python22\Li b\site-packages\Python win\pywin\frame work\scriptutil s.py",
line 301, in RunScript
exec codeObject in __main__.__dict __
File "C:\My Documents\Pytho n\Ascii\Script4 .py", line 6, in ?
win32api.SetCur sorPos(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.SetCur sorPos((100,100 )) does the trick.

--
Vincent Wehren
Thanks,
Gary Richardson


Jul 18 '05 #2

"vincent wehren" <vi*****@visual trans.de> wrote in message
news:ci******** **@news5.zwoll1 .ov.home.nl...
Gary Richardson wrote:
I'm trying to use win32api.SetCur sorPos() 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.SetCur sorPos(100,100)
root.mainloop()

But this code produces:

Traceback (most recent call last):
File
"C:\Python22\Li b\site-packages\Python win\pywin\frame work\scriptutil s.py", line 301, in RunScript
exec codeObject in __main__.__dict __
File "C:\My Documents\Pytho n\Ascii\Script4 .py", line 6, in ?
win32api.SetCur sorPos(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.SetCur sorPos((100,100 )) does the trick.

--
Vincent Wehren


I tried that. It doesn't produce an error but no cursor appears.
Jul 18 '05 #3
Am Samstag, 18. September 2004 22:41 schrieb Gary Richardson:
I tried that. It doesn't produce an error but no cursor appears.


I don't know much about the win32-api, but SetCursorPos sounds like a
text-console command, not like something that has to do with windows.
Funtions that operate on a window take a HWND (window handle), but this
function doesn't, so this certainly sounds like text-console.

Now, why are you trying to position the cursor in a Tk Window anyway? The
Tk-Window is no text console, it's just a plain window on the screen, and you
can draw in the window using the normal Tk drawing primitives.

Maybe, if you post some more info on what you're trying to do, can we help you
better...

Heiko.
Jul 18 '05 #4

"Heiko Wundram" <he*****@ceosg. de> wrote in message
news:ma******** *************** *************** @python.org...
Am Samstag, 18. September 2004 22:41 schrieb Gary Richardson:
I tried that. It doesn't produce an error but no cursor appears.
I don't know much about the win32-api, but SetCursorPos sounds like a
text-console command, not like something that has to do with windows.
Funtions that operate on a window take a HWND (window handle), but this
function doesn't, so this certainly sounds like text-console.

Now, why are you trying to position the cursor in a Tk Window anyway? The
Tk-Window is no text console, it's just a plain window on the screen, and

you can draw in the window using the normal Tk drawing primitives.

Maybe, if you post some more info on what you're trying to do, can we help you better...

Heiko.


Heiko,

Thank you for your reply. It encouraged me to read the MSVS documentation on
cursors a little more closely and to try a few things. I found that the
win32api function GetCursorPos() returns the position of the cursor with
respect to the computer screen so assuming that SetCursorPos() uses the same
coordinate system, I would have to add to my window coordinates the position
of the canvas with respect to the screen. I then took another look at
Vincent Wehren's and DogWalker's (direct email) suggestion that I pass
SetCursorPos() a tuple instead of a pair of values and found that did indeed
work. The cursor was there, it just wasn't where I expected it to be.

I'm using a Tk Canvas window to display various objects, one of which can be
a block of text entered from the keyboard. The user positions the cursor to
the desired position and begins typing, terminating the entry by pressing
the Esc key. From that point the text block can be manipulated (moved,
copied or deleted) by means of the mouse. As it is now, during text entry,
there is no indication of where the next character is to be entered. So I
thought it would be nice if I could indicate the insertion point as is usual
with text entry programs, editors, etc.

Thanks for all the help.

Gary

Jul 18 '05 #5
Gary Richardson wrote:
I'm using a Tk Canvas window to display various objects, one of which can be
a block of text entered from the keyboard. The user positions the cursor to
the desired position and begins typing, terminating the entry by pressing
the Esc key. From that point the text block can be manipulated (moved,
copied or deleted) by means of the mouse. As it is now, during text entry,
there is no indication of where the next character is to be entered. So I
thought it would be nice if I could indicate the insertion point as is usual
with text entry programs, editors, etc.


that's what the icursor method is there for. see:

http://effbot.org/zone/editing-canvas-text-items.htm

</F>

Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
48228
by: Matt Smith | last post by:
hi all, again.... having another problem with python COMs, I run a python script on a win2000 machine, that uses win32com.client and it runs perfectly, whereas when I come to run it on a win98 machine (the machine that the code, when completed, will be running from in the future) it returns the error: Traceback (most recent call last): File "firsttry.py", line 1, in ?
2
4152
by: Josh | last post by:
Hi All, I am trying to print a pdf file from python using the Win32api shellexecute method and am having a problem, or perhaps just a misunderstanding, with the bshow parameter. Am I correct to assume that if the bshow parm is set to 0, that the program will not show when launched? e.g.: win32api.ShellExecute (0, "print", "test.pdf", None, ".", 0)
2
1953
by: Nurchi BECHED | last post by:
Hello, my dearest respected brother, All! How do you make calls to Win32Api functions from C# I have an old example in Visual FoxPro... Kind of need to do the same in C# now... I need to get volume information (as much as possible) I am sure .Net Framework has already got something to do with it, but I am also interested (in learning purposes) how to do the same using Win32Api. Here goes a part of Visual FoxPro example:
2
2820
by: Jim | last post by:
I am trying to figure out how to embed Python in a little C++ Windows console app. Here's the code: // Py_Initialize(); Py_InitializeEx(0); PyRun_SimpleString("from win32com.client import *"); Here's what it does on the last line: File "D:\Python\Lib\site-packages\win32com\__init__.py", line 5, in ?
0
3819
by: Mike | last post by:
Hi. I have Python 2.4 installed on my local machine in c:\Python24. I have also downloaded the python for windows extensions installer pywin32-208.win32-py2.4.exe and installed this to C:\Python24\Lib\site-packages Trying to run a python script through a C# console app is causing me problems: the last line of code in the following block results in a no module named win32ap error. I'm not sure if this is because there is no
5
2960
by: __schronos__ | last post by:
Hi all. Recently I've to developed a project in python that made operation under win32 platform and I found a lot of problema to find good information. The only one documentation is in ActivePython page (http://aspn.activestate.com/ASPN/docs/ASPNTOC-APYTH2.4.0) but it is not very good and finally I had to turn to the newsgroups (it was very nice). And the question is: ¿Anybody knows where can I find good
1
6206
by: reginpc | last post by:
Hi, Please anyone say how to find win32api.py file and where its present?? i am Getting the below error... from win32com.shell import shell File "C:\Python25\Lib\site-packages\win32com\__init__.py", line 5, in <module> import win32api, sys, os ImportError: No module named win32api
1
1921
by: tkpmep | last post by:
I'm running Python 2.5.2 on Windows XP and need to interface with R, so I downloaded the R 2.6.2 statistical package and installed it, and did the same for RPy 1.02 (i made sure I got the version for Python 2.5 and R 2.62.). When I go to the Python command line and type I get the following error message: Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> from rpy import *
1
2832
by: Michiel Overtoom | last post by:
On Saturday 19 July 2008 21:13:04 Lamonte Harris wrote: What are the actions you do and the commands you give, and what is the precise error you get? Greetings, -- "The ability of the OSS process to collect and harness
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10371
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.