Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gusgitmath/color_print
A method to print things colorfully.
https://github.com/gusgitmath/color_print
Last synced: 5 days ago
JSON representation
A method to print things colorfully.
- Host: GitHub
- URL: https://github.com/gusgitmath/color_print
- Owner: GusGitMath
- Created: 2024-12-22T18:59:39.000Z (14 days ago)
- Default Branch: main
- Last Pushed: 2024-12-22T19:09:03.000Z (14 days ago)
- Last Synced: 2024-12-22T20:21:10.456Z (13 days ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ColorPrint Utility
## Overview
`ColorPrint` is a Python utility class designed to make terminal text output more dynamic and visually appealing by leveraging ANSI escape codes for colored text, text styles, and background highlights.## Features
- Print colored text to the terminal.
- Add text styles such as bold and underline.
- Use background highlights for emphasis.
- Create and display solid color bars for separators or visual breaks.## How to Use
### 1. Colorizing Text
You can use the `colorize` method to return a formatted string with specified color, style, and highlight:```python
from color_print import ColorPrinttext = ColorPrint.colorize("Hello, World!", color="blue", style="bold", highlight="yellow")
print(text)
```### 2. Printing with Styles
The `print` method simplifies printing directly to the terminal with the desired styles:```python
ColorPrint.print("Important Message", color="red", style="bold", highlight="white")
```### 3. Creating a Color Bar
Use `color_bar` to create a visual separator:```python
ColorPrint.color_bar(width=50, char="*", color="cyan", highlight="magenta")
```## Customization Options
### Colors
Supported text colors:
- `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `reset`### Styles
Supported text styles:
- `bold`, `underline`, `reset`### Highlights
Supported background colors:
- `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `reset`## Example Use Case
```python
ColorPrint.print("Welcome to ColorPrint!", color="green", style="bold")
ColorPrint.color_bar(width=40, char="=", color="yellow")
ColorPrint.print("Error: Something went wrong!", color="red", highlight="white")
```## Requirements
No external libraries are required. Works with Python 3.6+.