Please help with python and "curses"!

Antaeus Feldspar feldspar at cryogen.com
Mon Jan 28 21:06:15 CET 2002


I've only recently started working with the curses module, which was
installed for me along with Python 1.5.2 .  I have two tutorials that
I've been reading from, but both of them have been advising me to use
functions that don't appear to work.  The following Python script should
indicate two places I'm having trouble:


#! /usr/bin/python

import curses

stdscr = curses.initscr()
# start_color() 
curses.noecho()
stdscr.keypad(1) # Turns on keypad mode

stdscr.box() 

secondwin = curses.newwin(10,10,2,1)
secondwin.box()
secondwin.refresh()
stdscr.refresh()

g = stdscr.getch() 
while g != ord("q"):
        g = stdscr.getch()

stdscr.keypad(0) # Turns off keypad mode (We hope!)
curses.echo() 
curses.endwin()


Note the commented-out "start_color()" line.  This is listed in the
tutorial at http://py-howto.sourceforge.net/curses/curses.html as a
command I should use previous to calling "has_colors()" to find out if
the terminal actually supports colors.  Yet the "start_color()" line by
itself will terminate the script.  I have tried variations, such as
curses.start_color() and stdscr.start_color() , to no avail.

The second major problem I'm having is that the other tutorial (
http://www-106.ibm.com/developerworks/linux/library/l-python6.html )
says that a curses.newwin command such as in the above line "secondwin =
curses.newwin(10,10,2,1)" should create a new window that will appear
above the window referred to by stdscr.  However, I can't get any such
window to appear.

Please help me figure out why curses seems to be working much
differently for me than for everyone else?  =/

        -jc



More information about the Python-list mailing list