473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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
Jul 18 '05 #1
0 2307

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

Similar topics

0
by: Tim Clark | last post by:
We've been having a lot of event ID 37 with src W3SVC errors popping up. We have 50+ sites in medium isolation, and i ran IISstate on the two instances of DLLHOST and the one of inetinfo. Is there...
5
by: Sinan Nalkaya | last post by:
hello, i need a function like that, wait 5 seconds: (during wait) do the function but function waits for keyboard input so if you dont enter any it waits forever. i tried time.sleep() but when...
7
by: Christoph Zwerschke | last post by:
The latest Windows distribution of Python 2.4.2 is using the msvcrt71.dll, while PostgreSQL is using msvcrt.dll. This lead to the following problem: I was using PyGreSQL to connect to the...
3
by: simonharrison | last post by:
Hello everyone. Hopefully someone can point me in the right direction here. I'm wanting to write a script to open microsoft word and adobe pdf documents . Here is a little background: At the...
7
by: sturlamolden | last post by:
This question has been asked many times, and last time I was accused of spreading FUD. So now I will rather propose a solution. The reason for the problem is as follows: The binary installer...
11
by: Dick Moores | last post by:
Windows XP Pro, Python 2.5.1 import msvcrt while True: if msvcrt.kbhit(): key = msvcrt.getch() if key == 'Enter' do something Is there a way to catch the pressing of the 'Enter' key?
20
by: weheh | last post by:
Dear web gods: After much, much, much struggle with unicode, many an hour reading all the examples online, coding them, testing them, ripping them apart and putting them back together, I am...
1
by: SpecialKay | last post by:
hey guys, i have a threaded program, i have loop that contunes until i get a kbhit() then, i playback repetively untill i get another kbhit(). EDIT: the first kbhit happens on a child thread of...
6
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.