Package for manage colors in console
Project description
Introduction
tty-color is a Python package for manage a console colors
Install
Python pip
pip install tty-color
Python direct install
- Download archive & extract
python setup.py install
Usage
Import
from ttycolor import Color
Create an instance of Color class. In examples, color is instance of Color
Standard ANSI colors
print(text, code)
Print text with the ANSI code. Automatically add RESET ANSI code after text.
color.print('Your text', CODE)
CODE is a constant of Color class.
color(text, code)
Return text with the ANSI code. Not automatically add RESET ANSI code.
print(color.color('Your text', CODE)
CODE is a constant of Color class.
Extended ANSI colors
printrgb(text, r, g, b, type)
Print text with the RGB color. Automatically add RESET ANSI code after text.
color.printrgb('Your text', 255, 0, 0)
In example, display a red text. If type not established, the FG (foreground) constant used.
Type is FG or BG constant. If used other value, the Foreground (FG constant) used.
colorrgb(text, r, g, b, type)
Return text with the RGB color. Not automatically add RESET ANSI code.
color.colorrgb('Your text', 0x0C, 0x0C, 0x0C, color.BG)
In example, display a text with the grey background. If type not established, the FG (foreground) constant used.
Type is FG or BG constant. If used other value, the Foreground (FG constant) used.
List of standard ANSI code
- RESET : reset to the default color
- BOLD : bold text
- FAINT
- ITALIC : italic text
- UNDERLINE : underline text
- SLOW_BLINK : blink slowly (if console accept blink)
- BLINK : blink (if console accept blink)
- BLACK : black foreground color
- RED : red foreground color
- GREEN : green foreground color
- YELLOW : yellow foreground color
- BLUE : blue foreground color
- MAGENTA : magenta foreground color
- CYAN : cyan foreground color
- WHITE : white foreground color
- GREY : grey foreground color
- LIGHT_RED : light red foreground color
- LIGHT_GREEN : light green foreground color
- LIGHT_YELLOW : light yellow foreground color
- LIGHT_BLUE : light blue foreground color
- LIGHT_MAGENTA : light magenta foreground color
- LIGHT_CYAN : light cyan foreground color
- LIGHT_WHITE : light white foreground color
- All colors prefixed by : BG_ is for background color
Credits
Package developed by Christophe Daloz - De Los Rios christophedlr@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tty_color-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc0bdd034d0bd5ff7ffa755cb6e7600feb0525998905cccd614e93e3d0c46db2 |
|
MD5 | bd8511095e7389e677dcc972b252b1f1 |
|
BLAKE2b-256 | f1ac434e34bb954cdc4b258ec8e5eff17aed600424559b0c72c0eb2199a83c0b |