ncurses和黑底白字 [英] ncurses and white-on-black

查看:62
本文介绍了ncurses和黑底白字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在彩色模式下,我似乎无法用白底黑字来诅咒.如果我不打电话给start_color,我会变成黑白色.我一呼叫start_color,事情就开始以灰黑色输出.

I can't seem to get white-on-black to work in curses when in color mode. If I don't call start_color, I get white-on-black. As soon as I call start_color, things start outputting in grey-on-black.

如果运行此脚本:

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.

...you'll probably see a lot of pretty colors. The one I want, and can't get, is the last line: '...and this is normal.' Asking for color pair 0 or asking for COLOR_WHITE, COLOR_BLACK gets me the non-bright #37 from the script.

作为参考,这是我在Gnome终端中看到的内容:

For reference, this is what I see in Gnome Terminal:

http://rpi.edu/~wellir/random/colors.png

我正在使用Python编程(使用curses库),所以我的代码类似于:

I'm programming in Python (using the curses library), so my code is something like:

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岁明亮,37岁.

...which gets me 37, 37-bright, and 37.

推荐答案

curses.use_default_colors()

这篇关于ncurses和黑底白字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆