Please help with python and "curses"!

Antaeus Feldspar feldspar at
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() 
stdscr.keypad(1) # Turns on keypad mode 

secondwin = curses.newwin(10,10,2,1)

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

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

Note the commented-out "start_color()" line.  This is listed in the
tutorial at 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 ( )
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?  =/


More information about the Python-list mailing list