Skip to main content

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


Download files

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

Source Distribution

tty-color-1.0.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tty_color-1.0.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file tty-color-1.0.0.tar.gz.

File metadata

  • Download URL: tty-color-1.0.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for tty-color-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c2f842ef4255ed6bcadbd3753c398aeb19e42f763d1ba4df8c9919d0461197bf
MD5 c787c33f4a3e1e6a1528dde226be4058
BLAKE2b-256 c342ce8e8569ea1f141747bc10ef5de66e5180ffe674c8e4a2f16ef1fa6623af

See more details on using hashes here.

File details

Details for the file tty_color-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tty_color-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for tty_color-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc0bdd034d0bd5ff7ffa755cb6e7600feb0525998905cccd614e93e3d0c46db2
MD5 bd8511095e7389e677dcc972b252b1f1
BLAKE2b-256 f1ac434e34bb954cdc4b258ec8e5eff17aed600424559b0c72c0eb2199a83c0b

See more details on using hashes here.

Supported by

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