Skip to main content

A simple package to change text color in CMD prompt using ANSI escape codes

Project description

Chalk

Chalk is a simple Python package that allows you to change the color of your text in the terminal using ANSI escape codes. With this package, you can easily print colorful text to the command line, perfect for making your console outputs more vibrant.

Installation

You can install Chalk from PyPI using pip:

pip install chalkx

Usage

Basic Example

Use the chalk function to color your text. The color parameter accepts standard color names as strings, or you can use the COLORS dictionary.

from chalk import chalk, COLORS

# Simple usage with color name
print(chalk("This is red text", color="red"))
print(chalk("This is blue text", color="blue"))

# Using the COLORS dictionary
print(chalk("This is green text", color=COLORS.green))
print(chalk("This is yellow text", color=COLORS.yellow))

Erasing Colors

You can also remove the color formatting from text by using the erase=True option. This strips any previous color codes from the text and shows the raw output.

from chalk import chalk, COLORS

# Using erase to clean up the colors
colored_text = chalk("This is red text", color=COLORS.red)
print(colored_text)  # Shows red text
print(chalk(colored_text, erase=True))  # Erases the color, showing plain text

Available Colors

Chalk supports the following colors:

  • "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"
  • Bright variations: "bred", "bgreen", "byellow", "bblue", "bmagenta", "bcyan", "bwhite"
  • Grayscale: "grey", "gray"

These colors can be passed as strings or accessed via the COLORS dictionary.

# Using colors as strings
print(chalk("This is black text", color="black"))

# Using colors from the COLORS dictionary
print(chalk("This is cyan text", color=COLORS.cyan))

Contributing

Feel free to open issues or submit pull requests. All contributions are welcome!

License

MIT License. See 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

chalkx-0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

chalkx-0.2-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file chalkx-0.2.tar.gz.

File metadata

  • Download URL: chalkx-0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for chalkx-0.2.tar.gz
Algorithm Hash digest
SHA256 f6c29f0b1aa70d97d4af512da0c4276b61f07b6762052b580b4d1a499d2622d2
MD5 3fd780c5ba6ca6f668f7a6fceb3b45a7
BLAKE2b-256 f04f0cfa2b3ed29f1363e1ce26cc9443523690be5b2d88cb882bd0bacda18f08

See more details on using hashes here.

File details

Details for the file chalkx-0.2-py3-none-any.whl.

File metadata

  • Download URL: chalkx-0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for chalkx-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ec074a0bba20c845f57d7da91db3885c80c4619f6f7d09665a354a23c629e29
MD5 c56e665730ef4871d9f7d28aa21eed39
BLAKE2b-256 9c30450983780ee0815f47cd91baa7495e0b3ace915e28765cffc04a923ac598

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