Skip to main content

tcolopy is a Python library to apply true color for terminal text.

Project description

Summary

tcolopy is a Python library to apply true color for terminal text.

PyPI package version conda-forge package version Supported Python implementations Supported Python versions CI status of Linux/macOS/Windows CodeQL Test coverage: coveralls

Installation

Installation: pip

pip install tcolorpy

Installation: conda

conda install -c conda-forge tcolorpy

Usage

Library usage

Sample Code:
from tcolorpy import tcolor

print(tcolor("tcolopy example", color="#ee1177", styles=["bold", "italic", "underline"]))
Output:
https://github.com/thombashi/tcolorpy/blob/master/ss/oneline.png

You can set the following tcolor arguments:

  • color/bg_color
    • color names ("red", "green", etc.) or color code ("#RRGGBB")

  • styles
    • "bold", "italic", etc.

Other examples

Apply true color and styles to text:

https://github.com/thombashi/tcolorpy/blob/master/ss/styles.png

example source code

You can also specify colors by name:

https://github.com/thombashi/tcolorpy/blob/master/ss/ansi_colors.png

example source code

CLI usage

tcolorpy can be used via CLI:

$ python3 -m tcolorpy "tcolopy example" -c "#ee1177" -s bold,italic,underline

Command help

usage: __main__.py [-h] [-c COLOR] [-b BG_COLOR] [-s STYLES] [--encode ENCODE] string

positional arguments:
  string                string to apply styles.

options:
  -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 style. valid values are: bold, dim, italic, underline, blink, invert, strike
  --encode ENCODE       output a text encoded with the specified encoding

Dependencies

Python 3.7+ no external dependencies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tcolorpy-0.1.6.tar.gz (299.0 kB view hashes)

Uploaded Source

Built Distribution

tcolorpy-0.1.6-py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page