View Full Version : [SOLVED] Python: no colors in curses

March 8th, 2011, 10:11 AM
Hi all,

I can't get curses to show colors in Python. Even though curses.has_colors() returns True, .start_color doesn't, and any kind of formatting for stdscr.addstr and the like doesn't work as well. Everything shows as black, except for A_STANDOUT, which shows as grey on grey.

I'm using xterm with KDE, but also tried aterm, to no avail. Also tried with pythons 2.6, 2.7, 3.1 -- no difference.

Ansi color codes do work, but I'd prefer to do it in a nicer way :/

Any help would be greatly appreciated, as it's been driving me nuts since yesterday :)

March 8th, 2011, 11:41 PM

# color pair 1 = red text on white background
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)

stdscr.addstr( "Hello world", curses.color_pair(1) )

give that a shot.

March 9th, 2011, 11:09 AM
Thaks Johnl, that works :) It seems I was confused about color pairs and how they relate to attributes.