Skip to main content

A Python package for adding color and style to terminal text output

Project description

dexcolor

dexcolor is a Python package that provides a simple and convenient way to add color and style to text output in the terminal. It supports various ANSI escape sequences for text formatting and provides a cross-platform solution for both POSIX and Windows operating systems.

Installation

You can install dexcolor using pip:

pip install dexcolor

Usage

Using Colors Only

You can use dexcolor to add colors to your text. Available colors are:

  • GRAY
  • RED
  • GREEN
  • YELLOW
  • BLUE
  • MAGENTA
  • CYAN
  • WHITE
  • BRIGHT_BLACK
  • BRIGHT_RED
  • BRIGHT_GREEN
  • BRIGHT_YELLOW
  • BRIGHT_BLUE
  • BRIGHT_MAGENTA
  • BRIGHT_CYAN
  • BRIGHT_WHITE

Example:

from dexcolor import DEX

print(DEX.RED("Hello, World!"))

Using Colors and Styles

You can combine colors with styles to customize the appearance of your text even further. Available styles are:

  • BOLD
  • DIM
  • ITALIC
  • UNDERLINE
  • BLINK
  • REVERSE

Example:

from dexcolor import DEX

print(DEX.MAGENTA("Hello, World!", style='BOLD'))

Using Styles Only

You can also apply styles without any specific color:

from dexcolor import STYLE

print(STYLE.DIM("Hello, World!"))

Resetting Colors and Styles

To reset the text color and style to the default, you can use the RESET attribute:

from dexcolor import DEX

print(DEX.RED("Hello, World!") + DEX.RESET)
print(DEX.RED("Hello, World!", style='BOLD') + DEX.RESET)

Windows Compatibility

dexcolor is compatible with Windows operating systems. If you are working on Windows and want to convert ANSI escape sequences to the Win32 format, you can use the provided conversion function.

ANSI Escape Sequences Conversion (Windows)

To convert ANSI escape sequences to the Win32 format on Windows, you can use the following code:

from dexcolor import convert_ansi_to_win32

text = '\033[31mHello, World!\033[0m'  # Example text with ANSI escape sequences
converted_text = convert_ansi_to_win32(text)  # Convert ANSI escape sequences to Win32 format

print(converted_text)  # Display the converted text

This conversion function is specifically useful on Windows to ensure proper rendering of colored and styled text.

Compatibility

dexcolor is compatible with Linux, macOS, and Windows operating systems. It utilizes ANSI escape sequences, which are widely supported on various platforms.


If you have any questions or need further assistance, feel free to ask!

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

dexcolor-0.1.9.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

dexcolor-0.1.9-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file dexcolor-0.1.9.tar.gz.

File metadata

  • Download URL: dexcolor-0.1.9.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for dexcolor-0.1.9.tar.gz
Algorithm Hash digest
SHA256 200d7003f294365e0e000f9e9351576e5804c416d88c5014260fe79fd9e993fc
MD5 c6fe867ecda15a407f0695390ec408b1
BLAKE2b-256 95ab6b63b2c07458757f69bcdeb5c9246ef31da4c82479c4631f0148418f8e3a

See more details on using hashes here.

File details

Details for the file dexcolor-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: dexcolor-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for dexcolor-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 12fa31846e11476f12ae372489700624f4a952bcbd08670b2f616fa568081463
MD5 c5e3d0a45be8ef366f6467ef50949dde
BLAKE2b-256 96917ad396a6a6a465641aa00675bd054fc42ba3114b03d0448112732a3b3555

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