Colour of output text
garabik-news-2005-05 at kassiopeia.juls.savba.sk
garabik-news-2005-05 at kassiopeia.juls.savba.sk
Fri Jul 10 05:23:54 EDT 2009
Tim Harig <usernet at ilthio.net> wrote:
> On 2009-07-09, Alex Rosslyn <black.linen99 at gmail.com> wrote:
>> I would like to learn a way of changing the colour of a particular
>> part of the output text. I've tried the following
> On Unix operating systems this would be done through the curses interface:
>
> http://docs.python.org/library/curses.html
Or using ANSI colour codes:
colours = {
'none' : "",
'default' : "\033[0m",
'bold' : "\033[1m",
'underline' : "\033[4m",
'blink' : "\033[5m",
'reverse' : "\033[7m",
'concealed' : "\033[8m",
'black' : "\033[30m",
'red' : "\033[31m",
'green' : "\033[32m",
'yellow' : "\033[33m",
'blue' : "\033[34m",
'magenta' : "\033[35m",
'cyan' : "\033[36m",
'white' : "\033[37m",
'on_black' : "\033[40m",
'on_red' : "\033[41m",
'on_green' : "\033[42m",
'on_yellow' : "\033[43m",
'on_blue' : "\033[44m",
'on_magenta' : "\033[45m",
'on_cyan' : "\033[46m",
'on_white' : "\033[47m",
'beep' : "\007",
# non-standard attributes, supported by some terminals
'dark' : "\033[2m",
'italic' : "\033[3m",
'rapidblink' : "\033[6m",
'strikethrough': "\033[9m",
}
print colours['red'], 'this is red', colours['blue'], 'blue', colours['on_green'], 'and with a green background', colours['default']
--
-----------------------------------------------------------
| Radovan GarabĂk http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__ garabik @ kassiopeia.juls.savba.sk |
-----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
More information about the Python-list
mailing list