Screen Control in WinXP and Linux

Discussion in 'Python' started by peter, Apr 17, 2007.

  1. peter

    peter Guest

    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.

    My latest attempt is a throw back to the 1980's, using ANSI control
    codes. Seems to work on Linux, but not under Windows XP. I've found
    references to an application called ansi.com (didn't work), and
    instructions to modify the config.nt file to include

    dosonly
    device=%SystemRoot%\system32\ansi.sys

    then run command.com. I thought I was there - I could echo control
    codes satisfactorily, then when I tried to run python got an error
    message 'This program cannot be run in DOS mode'.

    Why is something which is apparently so simple such a hurdle? Other
    cross platform languages (euphoria, yabasic) seem to manage it. I
    don't have the expertise to write the code myself, but surely for the
    gurus this is not difficult.

    Any ideas? How can I run ansi.sys in WindowsXP. Can anyone come up
    with module with locate(), cls() and getch() functions? Is there any
    point in searching further?

    I realise this may come across as a bit petulant - not intended, but I
    am genuinely perplexed as to why this is such a show stopper.

    Peter
     
    peter, Apr 17, 2007
    #1
    1. Advertising

  2. En Tue, 17 Apr 2007 19:06:38 -0300, peter <>
    escribió:

    > 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.


    What about curses (Linux) and Console (XP)? You could wrap just the bits
    needed for your application in a more-or-less generic way.

    --
    Gabriel Genellina
     
    Gabriel Genellina, Apr 18, 2007
    #2
    1. Advertising

  3. peter

    Tim Golden Guest

    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
     
    Tim Golden, Apr 18, 2007
    #3
  4. peter

    peter Guest

    Thanks for these replies. Clearly what I'm looking for does not exist
    - yet!

    I've started by looking at Frederik Lundh's Console module. It looks
    promising, although on basis of ten minutes experience I can't yet
    figure out how to use it properly. Perhaps I should study Frederik's
    examples ....

    Peter
     
    peter, Apr 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grahammer
    Replies:
    0
    Views:
    560
    Grahammer
    Nov 8, 2003
  2. boney
    Replies:
    1
    Views:
    593
  3. Stylus277
    Replies:
    4
    Views:
    366
    Alex Buell
    Apr 12, 2006
  4. Kent
    Replies:
    5
    Views:
    406
    Mike Driscoll
    Apr 23, 2009
  5. Roman Hausner

    GUI programming for WinXP/Linux/OSX?

    Roman Hausner, Sep 26, 2006, in forum: Ruby
    Replies:
    40
    Views:
    431
    Roman Hausner
    Sep 28, 2006
Loading...

Share This Page