[Python-de] Curses mit Farbe
Gerhard Häring
gh_pythonlist at gmx.de
Wed Feb 13 12:25:59 EST 2002
So, und jetzt hab ich auch mal eine Frage :-)
Ich hab ziemliche Probleme, das curses-Modul von Python dazu zu bringen,
was farbiges auszugeben.
Ich gehe nach dem Python Curses HOWTO auf auf http://py-howto.sf.net/
vor, aber ich habe da schon so viele Fehler gefunden, dass mich nix mehr
wundert.
Ich probier mal, einen Testcase aufzustellen:
import curses
def mymain(stdscr):
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
stdscr.clear()
l = "lala"
#stdscr.addstr(0, 0, l, curses.pair_content(1)) #1
#stdscr.addstr(0, 0, l, curses.COLOR_BLUE) #2
stdscr.addstr(0, 0, l, curses.COLOR_RED) #2a
#stdscr.addstr(0, 0, str(curses.has_colors())) #3
#stdscr.addstr(0, 0, l, curses.A_REVERSE) #4
stdscr.refresh()
stdscr.getkey()
curses.wrapper(mymain)
[1] liefert: _curses.error: Argument 1 was out of range. (1..COLOR_PAIRS-1)
[2] schreibt "lele"
[2a] schreibt "mama" -- bin ich jetzt blöd oder was?
[3] liefert "1"
[4] funktioniert
Kommt curses von "curse"? ;-)
Gerhard
--
This sig powered by Python!
Außentemperatur in München: 12.9 °C Wind: 9.6 m/s
More information about the Python-de
mailing list