platform independent kbhit()
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
Are there other (more simple, pure python, true platform independent)
Hans Georg Krauthaeuser
Re: platform independent kbhit()
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
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
|All times are GMT. The time now is 04:05 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.