Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > platform independent kbhit()

Reply
Thread Tools

platform independent kbhit()

 
 
Hans Georg Krauthaeuser
Guest
Posts: n/a
 
      01-17-2005
Hey all,

this is probably a FAQ, but I didn't found the answer...

I use msvcrt.kbhit() to check for a user keyboard event on windows. But
now, I would prefer to make the module independent from the platform
used. I already know that I can use curses (on linux/unix) or Tkinter.
Also, I found this http://my.execpc.com/~geezer/software/kbhit.c C
source that has a kbhit() and a getch() for linux/unix that I can SWIG
to python.

Are there other (more simple, pure python, true platform independent)
possibilities?

Best regards
Hans Georg Krauthaeuser
--
www.uni-magdeburg.de/krauthae
 
Reply With Quote
 
 
 
 
Scott David Daniels
Guest
Posts: n/a
 
      01-17-2005
Hans Georg Krauthaeuser wrote:
> I use msvcrt.kbhit() to check for a user keyboard event on windows. But
> now, I would prefer to make the module independent from the platform
> used.

This is not in general possible; many machines do not have keyboards.
You can, perhaps, build one for yourself from a pair of implementations
or more. Portable software seldom comes from adding one platform at a
time that the software works on. Portable software comes from working
using only features common (or in rare circumstances available) on all
machines in your target set, and then adding enough tests to believe
the portability. CPython starts with the C89-supported environment as
its base. It tries hard to stick to that abstract machine. I assume
Jython does a similar thing using Java VM semantics that it trusts will
be common across implementations.

> I already know that I can use curses (on linux/unix) or Tkinter.
> Also, I found this http://my.execpc.com/~geezer/software/kbhit.c C
> source that has a kbhit() and a getch() for linux/unix that I can SWIG
> to python.

Either of these might be a good basis for your personal "all machines I
care about" semantics. If you use curses, make sure it doesn't impose
an extra constraint on all terminal access.

--Scott David Daniels

 
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
Platform Independent Forms/Programs with ASP.NET ibeetb ASP .Net 1 06-01-2004 05:29 PM
platform independent serialization of a long RA Scheltema C++ 10 01-24-2004 02:02 PM
platform independent serialization of a long RA Scheltema C Programming 10 01-24-2004 02:02 PM
Re: truly abstract (platform independent) pathnames Harald Hein Java 9 08-17-2003 01:01 PM
Platform-independent way to refer to execute path MK Python 1 06-25-2003 05:43 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57