A utility for constructing ANSI escape codes for terminal text styling.
Project description
Picasso
Picasso is a versatile Python module for styling text in terminal applications. It provides a set of tools for applying colors, text styles, and formatting to enhance text presentation in console outputs.
Table of Contents
About
Picasso is designed to help developers create visually appealing text outputs in terminal applications. With Picasso, you can easily apply various styles such as bold, italic, underline, and colorize text using hex, RGB, or HSL color formats. Whether you’re building a CLI tool or simply want to enhance your terminal logs, Picasso provides a flexible and powerful way to style your text.
Features
- Text Styling: Apply bold, italic, underline, strikethrough, and overline styles to your text.
- Color Support: Set foreground and background colors using hex, RGB, and HSL values.
- Brightness Adjustment: Modify the brightness of text colors.
- Decorators: Use decorators to apply styles to functions that return text.
- Formatter: Apply and manage styles efficiently with
StyleFormatter
.
Installation
To install Picasso, you can use pip
:
pip install picassocli
Ensure you have Python 3.6 or higher installed. Picasso is compatible with most terminal emulators that support ANSI escape codes for text styling.
Usage
Here are some basic examples to get you started with Picasso:
Using StyleComposer
from picasso import StyleComposer
# Create a StyleComposer instance
composer = StyleComposer()
# Set foreground color and apply bold style
composer.set_fg_color("#C4D600").set_bold()
print(f"{composer.build()}This text is bold with a custom color.{composer.reset_code}")
# Reset to default styles
composer.reset()
Using StyleFormatter
from picasso import StyleComposer, StyleFormatter
# Define a StyleComposer instance
composer = StyleComposer().set_bold().set_fg_color("#C4D600")
# Create a StyleFormatter instance
formatter = StyleFormatter(composer, print_mode=True)
# Use the formatter to print styled text
formatter("This is a bold text with a custom color.")
# Get styled text without printing
formatted_text = StyleFormatter(composer, print_mode=False)
print(formatted_text("This text is styled but not printed directly."))
Using StyleDecorator
from picasso import StyleComposer, StyleDecorator
# Define decorators
accent_decorator = StyleDecorator(StyleComposer().set_bold().set_fg_color("#FF5733"), stringify=False)
underline_decorator = StyleDecorator(StyleComposer().set_underline(), stringify=False)
def decorator_demo(text):
@accent_decorator
def decorated_accent():
return text
@underline_decorator
def decorated_underline():
return text
# Print decorated text
print("Accent Style:")
print(decorated_accent())
print("Underline Style:")
print(decorated_underline())
# Run the decorator demo
decorator_demo("This is a decorated text.")
Contributing
We welcome contributions to Picasso! If you'd like to contribute, please follow these guidelines:
- Fork the Repository: Create a fork of the repository on GitHub.
- Create a Branch: Create a new branch for your feature or bug fix.
- Make Changes: Implement your changes and test thoroughly.
- Submit a Pull Request: Submit a pull request with a clear description of your changes.
Please ensure your code adheres to the project's style guidelines and includes appropriate tests.
License
Picasso is licensed under the MIT License. See the LICENSE file for more 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
Built Distribution
File details
Details for the file picassocli-1.1.1.tar.gz
.
File metadata
- Download URL: picassocli-1.1.1.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8e58a90ebd1f0c3e78df449b5b4e42116ff2b238162f476e98548db1bf60ade |
|
MD5 | e1421b92eb11af0a40553b5be26c56ad |
|
BLAKE2b-256 | 75f68c24bc944c7d7ae1f6700ac1e86d0a3187c8887a3eda6e008f5dd486c4ec |
File details
Details for the file picassocli-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: picassocli-1.1.1-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fc594c4dc0abaa63c41cf65bca8b0ff3b81ca8e51a37fc3a7d93e3353a89c5c |
|
MD5 | 24e23ad2af5cb9640c960605ed97315b |
|
BLAKE2b-256 | a5f99d266f325827711a7162191a352c78b0d6627cdce5406ef2d14c53eddd62 |