Forum Archive

Colorama, see characters in color?

david

Hi al,
I have installed the package colorama but it seems that the console color characters are not displayed.

Minimal sample:

from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')

Output:

some red text
and with a green background
and in dim text

back to normal now

Does it alternative?
Best, David

ccc

http://omz-software.com/pythonista/docs/ios/console.html#console.set_color

dgelessus

The [31m and such that you're seeing there are ANSI escape codes, which almost all terminal programs support for changing foreground/background color and other text formatting. Pythonista's console isn't a normal terminal emulator though, so it doesn't support many terminal-like features, like escape codes. In Pythonista you can change the console text color using the console.set_color function that @ccc linked above.

david

Hi, then, this not what can I do?...

https://github.com/tartley/colorama/raw/master/screenshots/ubuntu-demo.png

zipit

Hi, then, this not what can I do?...

Depends on your definition of this. You cannot set the background color but you can set the text color and font. Just follow the link provided by @ccc or use the Pythonista documentation and look up the console module.

david

Hi, Many thanks to all. I will follow these indications.
I believe that they are sufficient for now.