tcolorpy
tcolopy is a Python library to apply true color for terminal text.
pip install tcolorpy
conda install -c conda-forge tcolorpy
- Sample Code
from tcolorpy import tcolor print(tcolor("tcolopy example", color="#ee1177", styles=["bold", "italic", "underline"]))
- Output
You can set the following tcolor
arguments:
color
/bg_color
- color names (
"red"
,"red"
, etc.) or color code ("#RRGGBB"
)
- color names (
styles
"bold"
,"italic"
, etc.
Apply true color and styles to text:
tcolorpy/ansi_styles.pyYou can also specify colors by names:
tcolorpy/ansi_colors.pytcolorpy
can be used via CLI:
$ python -m tcolorpy "tcolopy example" -c "#ee1177" -s bold,italic,underline
usage: __main__.py [-h] [-c COLOR] [-b BG_COLOR] [-s STYLES] [--encode ENCODE]
string
positional arguments:
string string to apply styles.
optional arguments:
-h, --help show this help message and exit
-c COLOR, --color COLOR
specify a color code (#XXXXXX) or a name. valid names
are: black, red, green, yellow, blue, magenta, cyan,
white, lightblack, lightred, lightgreen, lightyellow,
lightblue, lightmagenta, lightcyan, lightwhite
-b BG_COLOR, --bg-color BG_COLOR
specify a background color code (#XXXXXX) or a name.
valid names are: black, red, green, yellow, blue,
magenta, cyan, white, lightblack, lightred,
lightgreen, lightyellow, lightblue, lightmagenta,
lightcyan, lightwhite
-s STYLES, --styles STYLES
specify a comma separated styles. valid values are:
bold, dim, italic, underline, blink, invert, strike
--encode ENCODE output a text encoded with the specified encoding
Python 3.6+ No external dependencies.