Curses & Colors

Gerhard Häring gh_pythonlist at gmx.de
Fri Feb 15 06:02:07 CET 2002


Le 14/02/02 à 16:50, Rafael Mentz Aquino écrivit:
> Hi, there...
> 
> I'm creating some simple interfaces with curses with python under
> FreeBSD, but I'm having some problems to change colors. I tried to do
> something in /etc/termcap, but when I run curses.can_change_color(), I
> always obtain 0.  My env term is cons25, but I don't know if python
> uses the same terminal.  I'm running python 2.1.1. Can anybody help
> me...? ;-))

I recently fiddled with this, too. And it took me a while to get the
curses code right. What I *can* do is give you some source that will
work if color works at all:

import curses

def mymain(stdscr):
    curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
    stdscr.clear()

    stdscr.addstr(0, 0, "This text is red on white.", curses.color_pair(1))

    stdscr.refresh()
    stdscr.getkey()

curses.wrapper(mymain)

I've no solution for how to activate color on your FreeBSD console,
though. Maybe best ask on a FreeBSD group.

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: -0.7 °C      Wind: 4.1 m/s




More information about the Python-list mailing list