I'm working on a project for school right now, and I'm using curses. Although, I am a bit disappointed on the restrict of colors. The colorama module has LOTS more colors, and they work on my Terminal, so I know my terminal is capable of lots of colors. Although, in Curses, we only have
COLOR_BLACK
COLOR_RED
COLOR_GREEN
COLOR_YELLOW
COLOR_BLUE
COLOR_MAGENTA
COLOR_CYAN
COLOR_WHITE
It would be REALLY nice if there where more colors.
Note: Colorama gives ANSI escape codes, and doesn't work with Curses, so no shortcut there.
A color in curses is just a number from 0
to curses.COLORS - 1
. Those you listed are just the named constants curses provide you.
Curses supports 256 colors just fine, but it only enables that if your terminal identifies itself as a 256-color capable terminal via TERM
environmental variable.
While most modern terminals do support 256 colors for years, such as Gnome Terminal and Xterm, many still do not report as such.
If you run your program using env TERM=xterm-256color yourprogram
, curses will enable 256 colors, and it will work fine as long as your terminal actually supports it!
If it does work, change your terminal to automatically set its TERM
appropriately.
Recommended further reading:
http://blog.sanctum.geek.nz/term-strings/
http://blog.sanctum.geek.nz/256-colour-terminals/
https://unix.stackexchange.com/a/181766/4919
https://askubuntu.com/a/578798/11015
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With