Colore Textos¶
Módulo simples para colorir textos
@author: João Vitor G. Paes
- class pytta.utils.ColorStr(font: str = 'clear', back: str = 'clear')[source]¶
Color string
- __init__(font: str = 'clear', back: str = 'clear') None [source]¶
Pintor de linhas.
Example use:
>>> black_on_white_str = ColorStr("black", "white") >>> red_on_green_str = ColorStr("red", "green") >>> print(black_on_white_str("Estou usando colore.ColorStr")) >>> print(red_on_green_str("I'm using colore.ColorStr"))
- Parameters:
font (str, optional) – Cor da fonte | Font color. Defaults to “clear”.
back (str, optional) – Cor do fundo | Background color. Defaults to “clear”.
- Returns:
None.
- __call__(text: Optional[str] = None) str [source]¶
Paint the text with its font and background colors.
- Parameters:
text (str, optional) – The text to be painted. Defaults to None.
- Returns:
Colored text and background.
- Return type:
str
- property fntclr: str¶
Font color.
- property font: str¶
Alias for fntclr.
- property bgrclr: str¶
Background color.
- property background: str¶
Alias for bgrclr.
- property back: str¶
Alias for bgrclr.
- pytta.utils.colorir(texto: str, fntclr: Optional[str] = None, bgrclr: Optional[str] = None) str [source]¶
Retorna o texto colorido nas cores escolhidas.
Caso nenhuma cor seja informada, retorna o texto sem alterações.
- Parameters:
texto (str) – DESCRIPTION.
fntclr (str, optional) – Font color. Defaults to None.
bgrclr (str, optional) – Background color. Defaults to None.
- Returns:
Colored font and background.
- Return type:
texto (str)