Problems with curses

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Clay Hobbs

    Problems with curses

    I am making a text-based game similar to Zork with Python. I have
    decided to use the curses module, and have run into a problem. I want
    to scroll the commands and output up after a command is run instead of
    clearing the screen. But when I use std.scroll(), an exception is
    raised. Here is the program:

    #!/usr/bin/env python
    # text_adventure. py

    import curses
    import curses.wrapper

    def main(stdscr):
    curses.echo()
    stdscr.setscrre g(1, 24)
    score = 0
    moves = 0
    statusbar = stdscr.subwin(2 , 80, 0, 0)
    statusbar.addst r(0, 0, 'Dingo'+' '*(58-len('Dingo'))+' Score: %03d
    Moves: %03d'%(score, moves), curses.A_REVERS E)
    stdscr.addstr(2 4, 0, '')
    x = stdscr.getstr(2 4, 2)
    x = str(x)
    stdscr.refresh( )
    # stdscr.erase()
    stdscr.scroll(3 )
    statusbar.erase ()
    statusbar.addst r(0, 0, x+' '*(58-len(x))+'Score: %03d Moves: %
    03d'%(score, moves), curses.A_REVERS E)
    stdscr.addstr(2 4, 0, '')
    stdscr.getstr(2 4, 2)

    curses.wrapper( main)

    Unfortunately, the error message isn't very helpful. I'm just hoping
    somebody out there knows curses and has the answer.

    -- Ratfink


  • Marc 'BlackJack' Rintsch

    #2
    Re: Problems with curses

    On Sat, 12 Jul 2008 20:49:56 -0400, Clay Hobbs wrote:
    Unfortunately, the error message isn't very helpful.
    But it would be helpful to tell it. If you get exceptions, always
    copy'n'paste the traceback here. People might know what the exception
    means and share their wisdom.

    Ciao,
    Marc 'BlackJack' Rintsch

    Comment

    Working...