Screen Control in WinXP and Linux

Tim Golden mail at timgolden.me.uk
Wed Apr 18 03:56:26 EDT 2007


peter wrote:
> I've been wrestling on and off with this problem for over a year now,
> without success.  Basically, I am looking for a simple set of screen
> and keyboard manipulation commands that will run identically under
> Linux and Windows.  Nothing fancy - just clear the screen, print a
> string at an arbitrary xy position and detect a keystroke.  I've
> googled around this newsgroup and elsewhere, and come across various
> suggestions (and even posted my own partial solutions), but still
> haven't come up with an elegant solution.

OK, a bit of info from the Windows side of
things. Here are several existing modules
which offer the kind of thing you're after
in different ways. Don't bother with the
ANSI thing; it's a dead end under Windows.

   http://newcenturycomputers.net/projects/wconio.html
   http://effbot.org/zone/console-index.htm
   http://adamv.com/dev/python/curses/

I've used the first two for relatively trivial
things, the third not at all. The third is
interesting, obviously, because curses is
readily available on Linux (indeed comes as
part of Python, I think). So that might be
a quick win.

Alternatively, and depending on your needs,
there are a few UI addons for pygame:

   http://www.pygame.org/projects/9

Might not be what you're after from your
original description, but better too much
information than too little.

Obviously, unless the curses stuff fits your
needs, you might need to write a wrapper module
doing a bit of conditional importing or
platform-sniffing, but that's not beyond the wit
of man.

TJG



More information about the Python-list mailing list