TermTk.TTkCore.color

TTkColor

class TTkColor(fg: tuple = None, bg: tuple = None, mod: int = 0, colorMod=None, link: str = '', clean=False)[source]

TermTk Color helper

The TTkColor constructor creates the color based on HEX values.

Example:

# Foreground only colors:
color_fg_red   = TTkColor.fg('#FF0000')
color_fg_green = TTkColor.fg('#00FF00')
color_fg_blue  = TTkColor.fg('#0000FF')

# Background only colors:
color_bg_red   = TTkColor.bg('#FF0000')
color_bg_green = TTkColor.bg('#00FF00')
color_bg_blue  = TTkColor.bg('#0000FF')

# Combine
color_1 = color_fg_red + color_bg_blue
color_2 = color_fg_red + TTkColor.bg('#FFFF00')
color_3 = color_2 + TTkColor.UNDERLINE + TTkColor.BOLD

# Use presets
color_4 = TTkColor.RED
color_5 = TTkColor.BG_YELLOW + color_4
color_6 = color_5 + TTkColor.UNDERLINE + TTkColor.BOLD
BG_BLACK = <TermTk.TTkCore.color._TTkColor object>

(bg) #000000 - Black

BG_BLUE = <TermTk.TTkCore.color._TTkColor object>

(bg) #0000FF - Blue

BG_CYAN = <TermTk.TTkCore.color._TTkColor object>

(bg) #00FFFF - Cyan

BG_GREEN = <TermTk.TTkCore.color._TTkColor object>

(bg) #00FF00 - Green

BG_MAGENTA = <TermTk.TTkCore.color._TTkColor object>

(bg) #FF00FF - Magenta

BG_RED = <TermTk.TTkCore.color._TTkColor object>

(bg) #FF0000 - Red

BG_WHITE = <TermTk.TTkCore.color._TTkColor object>

(bg) #FFFFFF - White

BG_YELLOW = <TermTk.TTkCore.color._TTkColor object>

(bg) #FFFF00 - Yellow

BLACK = <TermTk.TTkCore.color._TTkColor object>

(fg) #000000 - Black

BLINKING = <TermTk.TTkCore.color._TTkColor object>

“Blinking” modifier

BLUE = <TermTk.TTkCore.color._TTkColor object>

(fg) #0000FF - Blue

BOLD = <TermTk.TTkCore.color._TTkColor object>

Bold modifier

CYAN = <TermTk.TTkCore.color._TTkColor object>

(fg) #00FFFF - Cyan

FG_BLACK = <TermTk.TTkCore.color._TTkColor object>

(fg) #000000 - Black

FG_BLUE = <TermTk.TTkCore.color._TTkColor object>

(fg) #0000FF - Blue

FG_CYAN = <TermTk.TTkCore.color._TTkColor object>

(fg) #00FFFF - Cyan

FG_GREEN = <TermTk.TTkCore.color._TTkColor object>

(fg) #00FF00 - Green

FG_MAGENTA = <TermTk.TTkCore.color._TTkColor object>

(fg) #FF00FF - Magenta

FG_RED = <TermTk.TTkCore.color._TTkColor object>

(fg) #FF0000 - Red

FG_WHITE = <TermTk.TTkCore.color._TTkColor object>

(fg) #FFFFFF - White

FG_YELLOW = <TermTk.TTkCore.color._TTkColor object>

(fg) #FFFF00 - Yellow

GREEN = <TermTk.TTkCore.color._TTkColor object>

(fg) #00FF00 - Green

ITALIC = <TermTk.TTkCore.color._TTkColor object>

Italic modifier

MAGENTA = <TermTk.TTkCore.color._TTkColor object>

(fg) #FF00FF - Magenta

RED = <TermTk.TTkCore.color._TTkColor object>

(fg) #FF0000 - Red

RST = <TermTk.TTkCore.color._TTkColor object>

Reset to the default terminal color and modifiers

STRIKETROUGH = <TermTk.TTkCore.color._TTkColor object>

Striketrough modifier

UNDERLINE = <TermTk.TTkCore.color._TTkColor object>

Underline modifier

WHITE = <TermTk.TTkCore.color._TTkColor object>

(fg) #FFFFFF - White

YELLOW = <TermTk.TTkCore.color._TTkColor object>

(fg) #FFFF00 - Yellow

static bg(*args, **kwargs)[source]

Helper to generate a Background color

Example:

color_1 = TTkColor.bg('#FF0000')
color_2 = TTkColor.bg(color='#00FF00')
color_3 = TTkColor.bg('#0000FF', modifier=TTkColorGradient(increment=6))
Parameters
  • color (str) – the color representation in (str)HEX

  • modifier (TTkColorModifier, optional) – (experimental) the color modifier to be used to improve the kinkiness

Returns

TTkColor

static fg(*args, **kwargs)[source]

Helper to generate a Foreground color

Example:

color_1 = TTkColor.fg('#FF0000')
color_2 = TTkColor.fg(color='#00FF00')
color_3 = TTkColor.fg('#0000FF', modifier=TTkColorGradient(increment=6))
Parameters
  • color (str) – the color representation in (str)HEX

  • modifier (TTkColorModifier, optional) – (experimental) the color modifier to be used to improve the kinkiness

Returns

TTkColor

static fgbg(fg: str = '', bg: str = '', link: str = '', modifier: _TTkColorModifier = None)[source]

Helper to generate a Background color

Example:

color_1 = TTkColor.fgbg('#FF0000','#0000FF')
color_2 = TTkColor.fgbg(fg='#00FF00',bg='#0000FF')
color_3 = TTkColor.fgbg('#0000FF','#0000FF', modifier=TTkColorGradient(increment=6))
Parameters
  • fg (str) – the foreground color representation in (str)HEX

  • bg (str) – the background color representation in (str)HEX

  • modifier (TTkColorModifier, optional) – (experimental) the color modifier to be used to improve the kinkiness

Returns

TTkColor