These Python functions allow you to print text with various colors and styles in your terminal with ANSI escape sequences
Project description
Python 3 Colorful Print Functions 🌈🖨️
These Python functions allow you to print text with various colors and styles in your terminal. Spice up your console output with these vibrant options! 🎨
With these functions, you can make your terminal output more engaging and colorful. Experiment with different colors and styles to create visually appealing text. 😊🚀
Note: To ensure the proper functionality of these functions, it is important that your terminal supports the ANSI standard for colored text formatting. Make sure your console is ANSI-compatible before using these functions to achieve the desired effect.
Supported Python Versions
- Python 3.6+
Installing
If you have pip on your system, you can simply install or upgrade the Python Module:
pip install -U python_print_color
Usage
To import the functions inside teh package simply use from python_print_color import * as shown in the example:
from python_print_color import *
print_color_8bits("8 Bit colored text example", foreground="red", background="white", styles=["italic", "underline"])
print_color_rgb("RGB colored text example", foreground=(0, 128, 128), background=(0, 0, 128), styles=["underline"])
Function: Print Color 8 Bits
print_color_8bits prints text using 8-bit color codes and optional text styles.
def print_color_8bits(text, foreground="reset", background="reset", styles=[]):
"""
Print colored text using 8-bit color codes and optional text styles.
Parameters:
- text (str): The text to be colored.
- foreground (str, optional): The foreground color name or code (default is "reset").
- background (str, optional): The background color name or code (default is "reset").
- styles (list, optional): A list of text styles to apply (e.g., ["bold", "italic"]).
Color and style codes are specified using string names or codes.
Supported color names: "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "default", "reset".
Supported style names: "bold", "dim", "italic", "underline", "blink", "reverse", "hidden", "strikethrough".
"""
Example Usage (8-bit Colors):
# Example 1: Print 8-bit colored text with bold style and a custom background color (e.g., green)
print_color_8bits("Bold text with green background", foreground="white", background="green", styles=["bold"])
# Example 2: Print 8-bit colored text with italic style and a custom foreground color (e.g., yellow)
print_color_8bits("Italic text with yellow foreground", foreground="yellow", styles=["italic"])
# Example 3: Print 8-bit colored text with underline style, a custom foreground color (e.g., red),
# and a custom background color (e.g., blue)
print_color_8bits("Underlined text with red foreground and blue background", foreground="red", background="blue", styles=["underline"])
Function: Print Color RGB 🌟
print_color_rgb prints text using RGB color codes and optional text styles.
def print_color_rgb(text, foreground=None, background=None, styles=[]):
"""
Print colored text using RGB color codes and optional text styles.
Parameters:
- text (str): The text to be colored.
- foreground (tuple, optional): RGB values for the foreground color (default is None).
- background (tuple, optional): RGB values for the background color (default is None).
- styles (list, optional): A list of text styles to apply (e.g., ["bold", "italic"]).
RGB values are specified as tuples with three integers in the range 0-255.
Supported style names: "bold", "dim", "italic", "underline", "blink", "reverse", "hidden", "strikethrough".
"""
Example Usage (RGB Colors):
# Example 4: Print RGB colored text with bold style and a custom background color (e.g., purple)
print_color_rgb("Bold text with purple background", foreground=(255, 255, 255), background=(128, 0, 128), styles=["bold"])
# Example 5: Print RGB colored text with italic style and a custom foreground color (e.g., orange)
print_color_rgb("Italic text with orange foreground", foreground=(255, 165, 0), styles=["italic"])
# Example 6: Print RGB colored text with underline style, a custom foreground color (e.g., teal),
# and a custom background color (e.g., navy blue)
print_color_rgb("Underlined text with teal foreground and navy blue background", foreground=(0, 128, 128), background=(0, 0, 128), styles=["underline"])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_print_color-0.0.2.tar.gz.
File metadata
- Download URL: python_print_color-0.0.2.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2fb4220b20241f82b17f97934619ced51955888d1b856342d4e31cff8fdd438
|
|
| MD5 |
810dadd5ebb6aa669f67843704bcf35e
|
|
| BLAKE2b-256 |
572399bb3f5231b928280b3b110b0f4680644d54031e9b9ec8b55d1552e4e3ad
|
File details
Details for the file python_print_color-0.0.2-py3-none-any.whl.
File metadata
- Download URL: python_print_color-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c74a786bc47387cd1d18cee631ec0fc76b295f4d9678e65baf0bdfcf956d3be9
|
|
| MD5 |
d8fb0b3dad82dee01d6066bef23ce0f4
|
|
| BLAKE2b-256 |
81e1411070ee7ee796f54da9e97dd3378e5b463acd50db8019c5078b77d46a73
|