color formating of the output
lorcat opened this issue · 4 comments
Hi! Many thanks for qtconsole. Myself and our users are using it almost every day.
There is one thing I would like to ask, maybe there is a way, but I could not find it in documentation.
I would like to have a control of custom color text output of the commands. If in linux terminal one could use special \e[1;31m
In qtconsole I do not see a simple way. Could someone guide me here?
Hey @lorcat, thanks for reporting. I don't understand what you mean by this
I would like to have a control of custom color text output of the commands
Could you post a screenshot to better understand your point?
This is how I understood the question:
In the terminal, one can use the special ANSI color codes (e.g. \e[1;31m
) to set the current color of the text. You can use this to add colors to your text output. Does QtConsole support ANSI?
I think QtConsole does support ANSI codes to some degree. For example, this works:
print("\033[1;32;40m Bright Green \n")
To work more easily with colors, python ships with the colorama
module. Try this:
import colorama
from colorama import Fore
# strip=False disables some windows specific conversion that qtconsole doesn't support
colorama.init(strip=False)
print(Fore.GREEN + 'This text is in green')
Hi! Sorry for the late response. Yes, the question would be - is there a way to control color output of the text within the qtconsole similar to what is done in linux terminal.
I see that stuff output within logging.error() or warning is highlighted in red, info() comes in blue.