在彩色模式下,我似乎无法让黑底白字在诅咒中工作。如果我不打电话start_color
,我会得到白底黑字。我一打电话start_color
,事情就开始以黑底灰输出。
如果您运行此脚本:
import sys
for i in xrange(30, 38):
print '\x1b[0;' + str(i) + 'm' + str(i) + ': Shiny colors \x1b[1m(bright)'
print '\x1b[0m...and this is normal.'
...您可能会看到很多漂亮的颜色。我想要但无法得到的是最后一行:“……这很正常。” 要求颜色对 0 或要求 COLOR_WHITE,COLOR_BLACK 让我从脚本中得到不亮的 #37。
作为参考,这是我在 Gnome 终端中看到的:
http://rpi.edu/~wellir/random/colors.png
我正在用 Python 编程(使用 curses 库),所以我的代码类似于:
import curses
screen = curses.initscr()
curses.start_color()
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
screen.clear()
screen.attrset(0)
screen.addstr('Hello')
screen.attrset(curses.A_BOLD)
screen.addstr('Hello')
screen.attrset(curses.color_pair(1))
screen.addstr('Hello')
screen.refresh()
curses.napms(5000)
curses.endwin()
...这让我有 37、37-bright 和 37。