0

I started a project on Ubuntu using Python curses library. All worked great, I used some colors, so its fancy, everything is A-OK. Then I wanted to run the script on Windows. Although the script runs just as it should on Linux, the main problem are the colors - or lack of them.

It's not that my console is not supporting them - curses.has_colors() returns True, curses.COLORS is 256, but the colors... are looking like a strange encoded escape characters.

Here's a sample of my test code:

win = curses.initscr()
if curses.has_colors():
    curses.start_color()
    curses.use_default_colors()
    for i in range(curses.COLORS - 1):
        curses.init_pair(i + 1, i , -1)
        win.addstr(str(i), curses.color_pair(i + 1))
    win.getch()

And here's what's printed to console: terminal colors

What am I doing wrong? I tried this on Windows Powershell, same result. Internet is telling me that it should work, but its not. Somebody help me? I'm using Windows 10 Pro.

sznowak13
  • 11
  • 5
  • Open a `cmd` prompt, type `color /?`. _Color attributes are specified by TWO hex digits -- the first corresponds to the background; the second the foreground_. This gives `16*16` = **256** combinations… Run `reg query HKEY_CURRENT_USER\Console -v ColorTable*` as well to see `RGB` values for all 16 used colors… – JosefZ Jun 14 '19 at 19:13
  • Possible duplicate of [How to make win32 console recognize ANSI/VT100 escape sequences?](https://stackoverflow.com/questions/16755142/how-to-make-win32-console-recognize-ansi-vt100-escape-sequences) – Thomas Dickey Jun 14 '19 at 19:52
  • Hey Thomas, thanks for providing similar thread, didn't encounter that one before. It seems like Windows cmd is kinda tricky when it comes to using curses. Thanks for hte help, I will try out provided solutions. – sznowak13 Jun 14 '19 at 23:16

0 Answers0