[Tutor] Problem with msvcrt
alan.gauld at btinternet.com
Thu Nov 1 08:59:47 CET 2007
"Ricardo Aráoz" <ricaraoz at gmail.com> wrote
> if msvcrt.kbhit() :
> key = msvcrt.getch()
> if key == 'h' :
> print 'Hello'
> This is XP with 2.5 in Idle. Any ideas?
IDLE is a GUI app running under Tkinters event loop.
I doubt if msvcrt works under Tkinter.
Try running your code in a DOS box.
Any solution that detects keyboard input will be
very sensitive to the operational environment.
Running in a GUI (any GUI) will cause keyboard
events that are handled by the GUI toolkit.
msvcrt is designed to catch keyboasrd events
within a DOS environment.
See the event handling page of my tutor for how
to detect keypresses within Tkinter.
Author of the Learn to Program web site
More information about the Tutor