how to set the background color of a window with curses
Gerhard Häring
gh_pythonlist at gmx.de
Sat Mar 9 11:42:04 EST 2002
Le 09/03/02 à 13:53, Marco Herrn écrivit:
> Hi,
>
> I am trying to set a backround color for a window and did it with
>
> stdscr.bkgd(' ', curses.COLOR_BLUE)
>
> But that doesn't work. It seems to do nothing.
> What am I doing wrong?
You're confusing colors with attributes. I recently stumbled across that
one, too :)
This will do the trick:
# define color 1 as black on blue
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_BLUE)
stdscr.bkgd(' ', curses.color_pair(1))
If you're getting this error:
File "clock.py", line 6, in mymain
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_BLUE)
_curses.error: must call start_color() first
your TERM setting doesn't allow colors. You can then use something like
TERM=xterm-color instead.
Btw. there's a curses howto on http://py-howto.sf.net/ in case you
didn't know.
Gerhard
--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9 3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
More information about the Python-list
mailing list