Problems with curses

C

Clay Hobbs

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.setscrreg(1, 24)
score = 0
moves = 0
statusbar = stdscr.subwin(2, 80, 0, 0)
statusbar.addstr(0, 0, 'Dingo'+' '*(58-len('Dingo'))+'Score: %03d
Moves: %03d'%(score, moves), curses.A_REVERSE)
stdscr.addstr(24, 0, '> ')
x = stdscr.getstr(24, 2)
x = str(x)
stdscr.refresh()
# stdscr.erase()
stdscr.scroll(3)
statusbar.erase()
statusbar.addstr(0, 0, x+' '*(58-len(x))+'Score: %03d Moves: %
03d'%(score, moves), curses.A_REVERSE)
stdscr.addstr(24, 0, '> ')
stdscr.getstr(24, 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
 
M

Marc 'BlackJack' Rintsch

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top