Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > help for using msvcrt.kbhit() with Python 2.3 editors?

Reply
Thread Tools

help for using msvcrt.kbhit() with Python 2.3 editors?

 
 
dbrown2@yahoo.com
Guest
Posts: n/a
 
      08-13-2003
I'm having some trouble using kbhit inside the editor enviroments. I'm
using win2000 with Python2.3 and win32all v157 versions.

Any pointer on how this should be handled would be appreciated. Is
there another non-blocking way to detect a key press?

Here's the code that is causing the trouble. If I run this by
double-clicking then it works as expected. But if I run from IDLE or
PythonWin it basically never returns. msvcrt.kbhit() always returns 0
as far as I can tell by adding print statements. I can't confirm it
but I seem to recall this worked at least with the PythonWin editor
environment under my previous Python 2.2 setup.

###########
import serial # access to serial port
import time # sleep command
import msvcrt # detect keyboard key press events

ser = serial.Serial(0, 4800, timeout=0.25)
data = ''
while not msvcrt.kbhit():
buf = ser.read(10)
if buf <> '': print buf
#time.sleep(1)
data = data + buf # concatenate buf onto data
ser.close()
###########

-- David
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. L÷wis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
I could use some help making this Python code run faster using only Python code. Python Maniac Python 24 09-23-2007 05:48 PM
Searching comp.lang.python/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments