Skip to main content

colorex-py is a simple and flexible Python Module that provides an easy way to style your terminal output with color and text formatting. With support for both RGB and HEX color codes, as well as text styles like bold, italic, underline, strikethrough, and more, it makes your terminal applications visually more appealing and readable.

Project description

colorex-py

colorex-py is a simple and flexible Python Module that provides an easy way to style your terminal output with color and text formatting. With support for both RGB and HEX color codes, as well as text styles like bold, italic, underline, strikethrough, and more, it makes your terminal applications visually more appealing and readable.

Features

  • RGB Color Support: Define colors using RGB values (e.g., color_rgb(255, 0, 0)).
  • HEX Color Support: Use HEX color codes (e.g., color_hex("#FF0000")).
  • Text Styles: Bold, italic, underline, strikethrough, dim, and inverted text.
  • Background Colors: Set the background color using RGB or HEX.
  • Chainable API: Apply multiple styles in a single statement using method chaining.

Installation

To install colorex-py, you can use pip:

pip install colorex-py

Usage

Here's how you can use colorex to add color and styles to your terminal output:

import colorex

# Basic color usage
print(f"{}", "Hello, World!".color("0,255,0"))  # Green text
print(f"{}", "Error!".color("#FF0000"))         # Red text

# Text styles
print(f"{}", "Bold Text".bold())                # Bold text
print(f"{}", "Italic Text".italic())            # Italic text
print(f"{}", "Underlined Text".underline())     # Underlined text
print(f"{}", "Strikethrough Text".strikethrough()) # Strikethrough text
print(f"{}", "Dim Text".dim());                  # Dim text
print(f"{}", "Inverted Text".invert())          # Inverted (background) text

# Background color
print(f"{}", "Background Color".bg_color("0,0,255")) # Blue background

# Combining multiple styles
print(f"{}", "ALL".color("0,255,0").bold().italic().underline().strikethrough().dim().invert().bg_color("0,0,255")) # All styles

Supported Styles

  • Color: RGB and HEX color formats.
  • Text Styles:
    • bold()
    • italic()
    • underline()
    • strikethrough()
    • dim()
    • invert()
  • Background Colors: bg_color() with RGB or HEX values.

Example Output

The following example would result in a green-colored "Hello, World!" and a red "Error!" message in the terminal.

print(f"{}", "Hello, World!".color("0,255,0"))  # Green text
print(f"{}", "Error!".color("#FF0000"))         # Red text

Supported Color Formats

  • RGB: "r,g,b" (e.g., "255,0,0" for red).
  • HEX: "#RRGGBB" (e.g., "#FF0000" for red).

License

This project is licensed under the MPL-2.0 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

colorex_py-0.1.3.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

colorex_py-0.1.3-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file colorex_py-0.1.3.tar.gz.

File metadata

  • Download URL: colorex_py-0.1.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.16 Linux/6.8.0-1020-azure

File hashes

Hashes for colorex_py-0.1.3.tar.gz
Algorithm Hash digest
SHA256 95b53d11a70b7c537466dd4dd2d508080fcad0c8bb4914ebdb31f77ce50ddf20
MD5 f2cac54b2d5c328bd0c25d32e8213d16
BLAKE2b-256 43333795ae0092fe6f0167375da5a1f7debb3348fa9d501072ad594e14b23a4c

See more details on using hashes here.

File details

Details for the file colorex_py-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: colorex_py-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.16 Linux/6.8.0-1020-azure

File hashes

Hashes for colorex_py-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5dc4a8e2e8f3c4ee516d0cc3d02e3c33cf25b65ac7c7b407878f208bb54a9c74
MD5 2c66ee6b0edcfe23b83020a192d42081
BLAKE2b-256 4d726556d43fe985421c41c58b9bd9d1ef5842130e74c8e5b5b43680af412f03

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