Skip to main content

Simple, Fast, Zero-Dependency Terminal Coloring

Project description

MyTColor

Version Python License

MyTColor provides a lightweight, dependency-free interface for ANSI terminal formatting in Python. It offers a straightforward API for adding colors and styles to terminal output, suitable for logging, CUI (Console User Interface) development, and script enhancements.

Key features:

  • Zero Dependencies: Pure Python implementation using standard libraries.
  • Cross-Platform: Native support for ANSI sequences on Linux, macOS, and automatic Virtual Terminal processing on Windows.
  • Performance: Uses static string constants for minimal runtime overhead.
  • Type Safety: Compatible with standard Python type checking.

Installation

Install via pip:

pip install MyTColor

Usage

MyTColor exposes ANSI sequences as string constants through the MyT class. This design allows for seamless integration with Python's f-strings.

Basic Example

from MyTColor import MyT

# Success message
print(f"{MyT.GREEN}✔ Operation completed successfully.{MyT.RESET}")

# Error message with style
print(f"{MyT.RED}{MyT.BOLD}✖ Error: Connection failed.{MyT.RESET}")

Advanced Formatting

Combine background colors, styles, and foreground colors for rich output.

# Header style: Bold white text on blue background
header_style = f"{MyT.BOLD}{MyT.BG_BLUE}{MyT.WHITE}"
print(f"{header_style} SYSTEM STATUS {MyT.RESET}")

API Reference

The MyT class provides the following constants.

Foreground Colors

Standard Accessor Bright Accessor
Black MyT.BLACK Black MyT.L_BLACK
Red MyT.RED Red MyT.L_RED
Green MyT.GREEN Green MyT.L_GREEN
Yellow MyT.YELLOW Yellow MyT.L_YELLOW
Blue MyT.BLUE Blue MyT.L_BLUE
Magenta MyT.MAGENTA Magenta MyT.L_MAGENTA
Cyan MyT.CYAN Cyan MyT.L_CYAN
White MyT.WHITE White MyT.L_WHITE

Background Colors

Prefix any color with BG_.

  • Example: MyT.BG_RED, MyT.BG_L_BLUE.

Styles

  • MyT.BOLD: Bold
  • MyT.DIM: Dim/Faint
  • MyT.ITALIC: Italic
  • MyT.UNDERLINE: Underline
  • MyT.BLINK: Blink
  • MyT.REVERSE: Invert colors
  • MyT.HIDDEN: Hidden text
  • MyT.STRIKETHROUGH: Strikethrough

Utilities

  • MyT.RESET: Resets all formatting. Essential to prevent style leakage.

Compatibility

MyTColor automatically enables standard ANSI support on Windows 10 and 11 terminals using ctypes. On Unix-like systems (Linux, macOS), it outputs standard ANSI sequences directly.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

mytcolor-1.0.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

mytcolor-1.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file mytcolor-1.0.1.tar.gz.

File metadata

  • Download URL: mytcolor-1.0.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for mytcolor-1.0.1.tar.gz
Algorithm Hash digest
SHA256 40db7dbdbeab7c6feb2a9fd4220a3fbfef2085819eee59e0e61e7605edff7862
MD5 edc23d73b9c685980aff00756786c376
BLAKE2b-256 b14a069bd76547bb218761e667957dccd480981c96e02a132cf6637b19bc417c

See more details on using hashes here.

File details

Details for the file mytcolor-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mytcolor-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for mytcolor-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9db03b643fbc7f6916008ddf129a13ca66e2275ee0f5132f6bd90dd4fde96575
MD5 9b259baa4efa4138d8583be3a20aa09c
BLAKE2b-256 81923cd689ce8ac9a1bd54f39b92cfbc9a1d08ba0e65dc53f3a259e53bbd1d22

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