Version: 8.3.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
termcolor

Functions

def termcolor.canDisplayColor
 Return True if the stream can display colored text, False otherwise. More...
 
def termcolor.getControlSequence
 Return the control sequence for the color in parameter, i.e. More...
 
def termcolor.makeColoredMessage
 Return a string that can be used to display the message in parameter with the given color. More...
 
def termcolor.TEST_termcolor
 Test function for termcolor module. More...
 

Variables

list termcolor.DEFAULT = ['00']
 Default color for the terminal. More...
 
list termcolor.BOLD = ['01']
 Bold text and brighter colors. More...
 
list termcolor.UNDERLINED = ['04']
 Underlined text. More...
 
list termcolor.BLACK_FG = ['30']
 Black foreground. More...
 
list termcolor.RED_FG = ['31']
 Red foreground. More...
 
list termcolor.GREEN_FG = ['32']
 Green foreground. More...
 
list termcolor.YELLOW_FG = ['33']
 Yellow foreground. More...
 
list termcolor.BLUE_FG = ['34']
 Blue foreground. More...
 
list termcolor.PURPLE_FG = ['35']
 Purple foreground. More...
 
list termcolor.CYAN_FG = ['36']
 Cyan foreground. More...
 
list termcolor.WHITE_FG = ['37']
 White foreground. More...
 
list termcolor.BLACK_BG = ['40']
 Black background. More...
 
list termcolor.RED_BG = ['41']
 Red background. More...
 
list termcolor.GREEN_BG = ['42']
 Green background. More...
 
list termcolor.YELLOW_BG = ['43']
 Yellow background. More...
 
list termcolor.BLUE_BG = ['44']
 Blue background. More...
 
list termcolor.PURPLE_BG = ['45']
 Purple background. More...
 
list termcolor.CYAN_BG = ['46']
 Cyan background. More...
 
list termcolor.WHITE_BG = ['47']
 White background. More...
 
 termcolor.BLACK = BLACK_FG
 Black text (equivalent to BLACK_FG) More...
 
 termcolor.RED = BOLD+RED_FG
 Red text (equivalent to BOLD + RED_FG) More...
 
 termcolor.GREEN = BOLD+GREEN_FG
 Green text (equivalent to BOLD + GREEN_FG) More...
 
 termcolor.YELLOW = BOLD+YELLOW_FG
 Yellow text (equivalent to BOLD + YELLOW_FG) More...
 
 termcolor.BLUE = BOLD+BLUE_FG
 Blue text (equivalent to BOLD + BLUE_FG) More...
 
 termcolor.PURPLE = BOLD+PURPLE_FG
 Purple text (equivalent to BOLD + PURPLE_FG) More...
 
 termcolor.CYAN = BOLD+CYAN_FG
 Cyan text (equivalent to BOLD + CYAN_FG) More...
 
 termcolor.WHITE = WHITE_FG
 White text (equivalent to WHITE_FG) More...
 

Detailed Description

This module provides utility functions to display colored text in the terminal. It is based on ISO 6429 standard that defines control codes to change characters representation in color-capable ASCII terminals.

In this module, colors are represented as lists of codes, so they can be added to obtain special effects (e.g. RED + GREEN_BG to display red text on green background). Several constants are defined for the most usual codes to facilitate the use of colors, but it is also possible to define colors directly from the corresponding code from ISO 6429 standard. In fact it is even necessary for less usual codes that don't have an associated constant (e.g. PURPLE + ['09'] can be used to display a crossed-out purple text).

1 import sys
2 from salome.kernel import termcolor
3 if termcolor.canDisplayColor(sys.stdout):
4  print termcolor.makeColoredMessage("Hello world!", termcolor.BLUE)
5 else:
6  print "Hello world!"

Function Documentation

def termcolor.canDisplayColor (   stream)

Return True if the stream can display colored text, False otherwise.

def termcolor.getControlSequence (   color)

Return the control sequence for the color in parameter, i.e.

the string telling the terminal to display the following text in the given color.

def termcolor.makeColoredMessage (   message,
  color 
)

Return a string that can be used to display the message in parameter with the given color.

def termcolor.TEST_termcolor ( )

Test function for termcolor module.

Variable Documentation

list termcolor.DEFAULT = ['00']

Default color for the terminal.

list termcolor.BOLD = ['01']

Bold text and brighter colors.

list termcolor.UNDERLINED = ['04']

Underlined text.

list termcolor.BLACK_FG = ['30']

Black foreground.

list termcolor.RED_FG = ['31']

Red foreground.

list termcolor.GREEN_FG = ['32']

Green foreground.

list termcolor.YELLOW_FG = ['33']

Yellow foreground.

list termcolor.BLUE_FG = ['34']

Blue foreground.

list termcolor.PURPLE_FG = ['35']

Purple foreground.

list termcolor.CYAN_FG = ['36']

Cyan foreground.

list termcolor.WHITE_FG = ['37']

White foreground.

list termcolor.BLACK_BG = ['40']

Black background.

list termcolor.RED_BG = ['41']

Red background.

list termcolor.GREEN_BG = ['42']

Green background.

list termcolor.YELLOW_BG = ['43']

Yellow background.

list termcolor.BLUE_BG = ['44']

Blue background.

list termcolor.PURPLE_BG = ['45']

Purple background.

list termcolor.CYAN_BG = ['46']

Cyan background.

list termcolor.WHITE_BG = ['47']

White background.

termcolor.BLACK = BLACK_FG

Black text (equivalent to BLACK_FG)

termcolor.RED = BOLD+RED_FG

Red text (equivalent to BOLD + RED_FG)

termcolor.GREEN = BOLD+GREEN_FG

Green text (equivalent to BOLD + GREEN_FG)

termcolor.YELLOW = BOLD+YELLOW_FG

Yellow text (equivalent to BOLD + YELLOW_FG)

termcolor.BLUE = BOLD+BLUE_FG

Blue text (equivalent to BOLD + BLUE_FG)

termcolor.PURPLE = BOLD+PURPLE_FG

Purple text (equivalent to BOLD + PURPLE_FG)

termcolor.CYAN = BOLD+CYAN_FG

Cyan text (equivalent to BOLD + CYAN_FG)

termcolor.WHITE = WHITE_FG

White text (equivalent to WHITE_FG)