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 chalk

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.1.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.1-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chalkx-0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 e698221d75343a86d62e1db0161dbbe7d27a8767508b8193a6f37e125f67c649
MD5 022bec27ffff3bb9d1e1c103f7f3332f
BLAKE2b-256 5a4fdaecb34c03080a72da895745db860f7cb7d26d3e15bb9c36b8cba0f8514c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkx-0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5be99e2ffbd32b6e851f0be47266f5e3688b3b73fea3879e1d9feb11a8f6e200
MD5 a72383d99a5752a52060e9c9eab16f4a
BLAKE2b-256 69533b265fb8c81207ee1e20ae712f59aeb6d8a91e279881c586197cfca92605

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