By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

Problems with curses.start_color()

P: n/a

Environment: Solaris 10, Python 2.4.2.

I'm trying to convert a very simple (display-wise) program to use curses.
This is my first try at using curses. I have wrapped my main:

try:
sys.exit(curses.wrapper(main, *sys.argv[1:]))
except (KeyboardInterrupt, SystemExit):
sys.exit(0)

According to the docs, curses.wrapper() calls curses.start_color(), but if I
don't call it myself I get this traceback when I try to use colors:

Traceback (most recent call last):
File "snake/scripts/message-tracker.py", line 141, in display
attr = curses.color_pair(0)
error: must call start_color() first

If I call start_color() unconditionally I get this error:

Traceback (most recent call last):
File "snake/scripts/message-tracker.py", line 229, in ?
sys.exit(curses.wrapper(main, *sys.argv[1:]))
File "/opt/app/g++lib6/python-2.4/lib/python2.4/curses/wrapper.py", line 44, in wrapper
return func(stdscr, *args, **kwds)
File "snake/scripts/message-tracker.py", line 215, in main
curses.start_color()
File "/opt/app/g++lib6/python-2.4/lib/python2.4/curses/__init__.py", line 41, in start_color
retval = _curses.start_color()
error: start_color() returned ERR

If I protect the call like so:

try:
curses.start_color()
except:
pass

I get the first traceback again.

A quick Google search didn't turn this up as an obvious problem. What have
I missed?

Thx,

Skip
Apr 10 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.