pg.colored

Accessible via pg.colored, pg.utils.colored.

colored(text, color=None, background=None, styles=None)[source]

Returns the colored text with ANSI color characters.

Return type:

str

Parameters:
  • text – A string that may or may not already has ANSI color characters.

  • color – A string for text colors. Applicable values are: ‘red’, ‘green’, ‘yellow’, ‘blue’, ‘magenta’, ‘cyan’, ‘white’.

  • background – A string for background colors. Applicable values are: ‘red’, ‘green’, ‘yellow’, ‘blue’, ‘magenta’, ‘cyan’, ‘white’.

  • styles – A list of strings for applying styles on the text. Applicable values are: ‘bold’, ‘dark’, ‘underline’, ‘blink’, ‘reverse’, ‘concealed’.

Returns:

A string with ANSI color characters embracing the entire text.