(original) (raw)
Hello all,
I was trying to set up a 'press any key to exit' mini-program similar to the one described here: http://www.freenetpages.co.uk/hp/alan.gauld/tutor2/tutevent.htm, but there seemse to be an issue with msvcrt.getch() on my computer (Windows XP Home, Python Version 2.3.4 final, IDLE version 1.0.3) when I ran it on IDLE. When I just type \[msvcrt.getch()\] at the prompt, it returns '\\xff' as shown below:
>>> msvcrt.getch()
'\\xff'
'\\xff'
This means that when I try running the script described at the above website, a space does squat, as demonstrated below:
>>>
Hit space to end...
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
... ##until i hit Control-C
Traceback (most recent call last):
File "C:/Documents and Settings/Cookie/Desktop/try.py", line 32, in ?
doKeyEvent(key)
File "C:/Documents and Settings/Cookie/Desktop/try.py", line 9, in doKeyEvent
print ord(key)
File "C:\\PROGRA\~1\\lib\\idlelib\\PyShell.py", line 1128, in write
self.shell.write(s, self.tags)
File "C:\\PROGRA\~1\\lib\\idlelib\\PyShell.py", line 1117, in write
raise KeyboardInterrupt
KeyboardInterrupt
File "C:/Documents and Settings/Cookie/Desktop/try.py", line 32, in ?
doKeyEvent(key)
File "C:/Documents and Settings/Cookie/Desktop/try.py", line 9, in doKeyEvent
print ord(key)
File "C:\\PROGRA\~1\\lib\\idlelib\\PyShell.py", line 1128, in write
self.shell.write(s, self.tags)
File "C:\\PROGRA\~1\\lib\\idlelib\\PyShell.py", line 1117, in write
raise KeyboardInterrupt
KeyboardInterrupt
The spaces before the '255' are points when i tried to exit using a space. A minor detail about the script at the site: it doesn't work as is, so i added a colon after the if-else lines in the first module and changed all references to 'ky' to 'key' for consistency. Any ideas as to why this doesn't work?
Thanks in advance,
Orri
P.S.: I just had a thought that perhaps it was something with IDLE, and since it \*does\* work on the Python command line, i suspect that there might be an issue with IDLE's way of handling msvcrt.getch().
Email: dragonfirebane@aol.com
AIM: singingxduck
Programming Python for the fun of it.
AIM: singingxduck
Programming Python for the fun of it.