A Python library to create pretty terminal output
Project description
PrettyPy
PrettyPy is a Python library that simplifies printing colored and styled messages in CLI applications. With PrettyPy, you can easily print status updates, error messages, and other types of messages with colored indicators that help them stand out.
The library offers a straightforward API for creating custom layouts, as well as a range of pre-built layouts that you can use to enhance the readability of your CLI applications.
PrettyPy uses ANSI escape codes to provide its coloring functionality, which is supported by most terminals. If your terminal does not support ANSI escape codes, you can set the no-color flag to disable the coloring functionality.
By using PrettyPy, you can create user-friendly CLI applications that are easier to read and more engaging.
Features
- Print messages with colors and styles
- Create custom layouts
- No color mode
- Table output
- Updating messages
- Progress bars
- Spinners
- Desktop notifications
Installation
pip install prettypy
Getting Started
The PrettyPy package is a Python library that provides an easy-to-use API for printing colored and styled messages in CLI applications. With the help of PrettyPy, you can quickly and easily print status updates, error messages, and other types of messages with colored indicators that help them stand out and improve the readability of your CLI applications.
To start using PrettyPy, you need to create an instance of the Pretty class. Once you have done this, you can use the Pretty class methods for each mode to print your messages. You can also use the Pretty class as a dictionary to access its modes, and you can even reassign Python's built-in print function to one of PrettyPy's modes.
If you need to create your own layouts, you can use the Composer class to customize the output even further. The Composer allows you to add new layouts, change the padding of the layout to align all your messages and improve the readability of your output.
Here's a code example that demonstrates how to use the PrettyPy package:
from prettypy import Pretty
# Create an instance of the Pretty class
pretty = Pretty()
# Use the Pretty class methods for each mode to print messages
pretty.info("This is an info message.")
pretty.success("This is a success message.")
# Access Pretty class modes as a dictionary
for mode in pretty:
pretty.__getattribute__(mode.name)(f"This is a {mode} message.")
# Reassign Python's built-in print function to one of PrettyPy's modes
print = pretty.neutral
print("This is a neutral message printed using the print function.")
# Use the Composer class to create new layouts
composer = pretty.get_composer()
pretty.add("test", "[TEST]", "red", text_format="bold")
# Use new layout created by the composer print method
pretty.test("This is a test message printed using the composer print method.")
# Change the padding of the layout with the Composer
composer.set_padding()
# Print messages again to demonstrate the padding
pretty.info("This is an info message.")
pretty.success("This is a success message.")
pretty.test("This is a test message printed using the composer print method.")
[i] This is an info message.
[✓] This is a success message.
[X] This is a error message.
...
With the PrettyPy package, you can make your CLI applications more user-friendly, readable, and engaging. The package is easy to use, and it allows you to quickly and easily create custom layouts to suit your needs.
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 prettypy-0.2.1.tar.gz
.
File metadata
- Download URL: prettypy-0.2.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f889bf98c573c3e8d01aaffc5133dd292c983b8508236c614f6899f1fef4a50e |
|
MD5 | 8b70960168d6c8589bf403009c5c5c10 |
|
BLAKE2b-256 | cd8eff8dc6584fd6506478089a0692f5063da69c7b4f6e3a2c4878693e44fb3b |
File details
Details for the file prettypy-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: prettypy-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 801a8af878e33fca3416e9160f0195a87bc212f68ffcae987cb94b013ec01449 |
|
MD5 | 2e74e9dd9c927d887a6fb9d43432173a |
|
BLAKE2b-256 | 91fe8a11bf7b4bbd2f111dc2d9d225ec2029cdd6705720472eda7380baccf615 |