TTkColor🌶️
- class TTkColor(fg: tuple[int] = None, bg: tuple[int] = None, colorMod=None, clean=False)[source]🌶️
Bases:
_TTkColor
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
Methods🌶️
- static bg(*args, **kwargs) None [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:
- static fg(*args, **kwargs) None [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:
- 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 Attributes🌶️
|
(bg) #000000 - Black |
|
(bg) #0000FF - Blue |
|
(bg) #00FFFF - Cyan |
|
(bg) #00FF00 - Green |
|
(bg) #FF00FF - Magenta |
|
(bg) #FF0000 - Red |
|
(bg) #FFFFFF - White |
|
(bg) #FFFF00 - Yellow |
|
(fg) #000000 - Black |
|
"Blinking" modifier |
|
(fg) #0000FF - Blue |
|
Bold modifier |
|
(fg) #00FFFF - Cyan |
|
(fg) #000000 - Black |
|
(fg) #0000FF - Blue |
|
(fg) #00FFFF - Cyan |
|
(fg) #00FF00 - Green |
|
(fg) #FF00FF - Magenta |
|
(fg) #FF0000 - Red |
|
(fg) #FFFFFF - White |
|
(fg) #FFFF00 - Yellow |
|
(fg) #00FF00 - Green |
|
Italic modifier |
|
(fg) #FF00FF - Magenta |
|
(fg) #FF0000 - Red |
|
Reset to the default terminal color and modifiers |
|
Striketrough modifier |
|
Underline modifier |
|
(fg) #FFFFFF - White |
|
(fg) #FFFF00 - Yellow |