私はこのようなものを使用しています: screen.addstr(text, color_pair(1) | A_BOLD), しかし、それは動作していないようです..しかし、A_REVERSEと他のすべての属性は動作します!
実際、私は何かを白で印刷しようとしていますが、COLOR_WHITEはそれを灰色で印刷します..しばらく検索した後、灰色+太字で印刷するとうまくいくようです!
どんな助けでも大歓迎です。
コードの例を次に示します (Python 2.6、Linux):
#!/usr/bin/env python
from itertools import cycle
import curses, contextlib, time
@contextlib.contextmanager
def curses_screen():
"""Contextmanager's version of curses.wrapper()."""
try:
stdscr=curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
try: curses.start_color()
except: pass
yield stdscr
finally:
stdscr.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
if __name__=="__main__":
with curses_screen() as stdscr:
c = curses.A_BOLD
if curses.has_colors():
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
c |= curses.color_pair(1)
curses.curs_set(0) # make cursor invisible
y, x = stdscr.getmaxyx()
for col in cycle((c, curses.A_BOLD)):
stdscr.erase()
stdscr.addstr(y//2, x//2, 'abc', col)
stdscr.refresh()
time.sleep(1)
すべてが機能しているようです。