3

I'm using a simple python (3.9.2) interpreter via command prompt on a windows 10 machine.

I am trying to get colored output texts from the python interpreter. I know how to get colored outputs however I'm looking for something that would allow RGB specified inputs so that I may output varying color intensities.

I found one thread HERE with such an example (you may have to scroll down to see the code line specifying the RGB input).

so.. I tried this part: (I also had to import colorama for ANY of the escape sequences to display actual color)

from sty import fg, bg, ef, rs

foo = fg.red + 'This is red text!' + fg.rs
qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs

# Add custom colors:

from sty import Style, RgbFg

fg.orange = Style(RgbFg(255, 150, 50))

buf = fg.orange + 'Yay, Im orange.' + fg.rs

print(foo, bar, baz, qux, qui, buf, sep='\n')

The fg.red worked okay, but the RGB specified lines did not produce the correct colors. nor the intensities. Is there anything else for suggestions where I can get this to work on a windows machine??

Anonymous
  • 31
  • 3
  • Is `colorama.init()` being called by chance? I discovered that even in the latest package version, calling this will break most extended color-support in Windows Terminal. `init()` is probably only designed to hook the console-output for older Windows support. Removing the `init()` call solved this same issue I was experiencing, with 24-bit rgb. – trigger_segfault Apr 03 '21 at 19:47
  • Sorry, I misread this as "Windows 10 Terminal" instead of "Command Prompt". The command prompt isn't able to output anything besides the 16 predefined colors at a time (foreground or background). There's an answer by SimpleBinary a few answers down from the one you were looking at that explains this limitation in a bit more detail. – trigger_segfault Apr 04 '21 at 05:19

0 Answers0