Skip to main content

terminalcolorpy

A lightweight, dependency-free package to colorize your terminal text.

Overview

This is a package that utilizes ANSI escape sequences to colorize your stdout, terminal, printed messages and what not. The key-features include,

  • Fully tested with pytest
  • Fully documented & type-hinted
  • Dependency-free

Installation

The required Python version for this module is 3.10 or above

# Linux/MacOS
python3 -m pip install terminalcolorpy

# Windows
py -m pip install terminalcolorpy

Usage

The package consists of a few functions which are explained down below. In case your terminal (which is common with Windows) doesn't display the color at all, please run the following code,

import os

os.system('')

# your code onwards




flip_text(text: str) -> str:

->  Flip text to characters that are upsidedown version of that letter.



prainbow(text: str) -> str:

->  Returns text in colors of the rainbow (RGB 1-255, not CSPRNG).



blink(message: str, length: float = 1, new_message: str = " ") -> None:

->  Print the message then replace it with a new message.


    Beware, this function is **blocking** because of the print statement. If you need to run this function
    synchronously, please refer to the accepted answer of this S/O question,
    https://stackoverflow.com/questions/54685210/calling-sync-functions-from-async-function

    Args:
        message (str): message to be printed
        length (float): how long should the message stay
        new_message (str): message to be displayed after the timer expires (default is nothing)



printcolor(colored_kwargs: dict = None, **kwargs) -> None:

->  Implements a shortcut for using the builtin function print with this modules colored function.

    Args:
        colored_kwargs (dict): keyword arguments for this modules colored function
        **kwargs: keyword arguments for the builtin print function



def colored(
    text: str,
    color: list | tuple | str,
    highlight: list | tuple | str | None = None,
    markup: list | tuple | None = None,
) -> str:
->  Parse color arguments and return the applied version to the text.

    Args:
        text (str): text to parse
        color (Union[list, tuple, str]): color for the text, accepts RGB, hex (str) and English words
        highlight ([list, tuple, str]): highlight for the text, accepts RGB, hex (str) and English words
        markup ([list, tuple]): markup from _Colors.color_dict

Metadata

Release files for terminalcolorpy 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terminalcolorpy 1.0.0
File Size Uploaded
terminalcolorpy-1.0.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for terminalcolorpy 1.0.0
File Interpreter ABI Platform
terminalcolorpy-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / terminalcolorpy-1.0.0.tar.gz

Download URL terminalcolorpy-1.0.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
191848866bd05bf9c2b44a3c7cae6e947221c77e876f8c4656a9660a980a551f
BLAKE2b-256 checksum
How to use checksums
fb0c13f5e5ac58a94ab16efe6c9da71e81b5f5502a2ccc5387745b481e97dd47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / terminalcolorpy-1.0.0-py3-none-any.whl

Download URL terminalcolorpy-1.0.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9787a1506ea2894fd5f3510fb7b8c2a886a96d092f4745da570be30d42d456c7
BLAKE2b-256 checksum
How to use checksums
ae720575482428a10fd9ef66c581fb40ebf3d29456796801a6a600dd306b9816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page