A Python library for flexible terminal text coloring using ANSI escape codes
Project description
pintar
A Python library for flexible terminal text coloring using ANSI escape codes.
Installation
pip install pintar
Quick Start
Color text with dye
from pintar import dye, RGB
# Foreground color with hex
text = dye("Hello world", "#FF5733")
print(text)
# Foreground and background
text = dye("Warning", fore="#FFFFFF", bg="#FF0000")
print(text)
# With style
text = dye("Bold text", fore="cyan", style="bold")
print(text)
Color text with pstr (tag syntax)
from pintar import pstr
pstr("[red]Red text[/]")
pstr("[bold][#FF5733]Bold orange[/][/]")
pstr("[green]Green on [on blue]blue background[/][/green]")
Reusable coloring with Brush
from pintar import Brush
red_bold = Brush.load(fore="#FF0000", style="bold")
print(red_bold("This text is red and bold"))
Color a substring with Stencil
from pintar import Stencil
s = Stencil("Hello cruel world", start=6, end=11)
print(s.spray(fore="#00FF00"))
Custom colors
from pintar import RGB, HSL, HEX
c1 = RGB(255, 128, 0)
c2 = HSL(210, 1.0, 0.5)
c3 = HEX("#3498db")
text = dye("Custom color", c1)
print(text)
256-color palette
from pintar import dye
dye.palette()
Supported color formats
| Format | Example |
|---|---|
| Hex string | "#FF5733" |
| Short hex | "#F00" |
| RGB tuple | (255, 0, 0) |
| RGB object | RGB(255, 0, 0) |
| HSL object | HSL(0, 1.0, 0.5) |
| HEX object | HEX("#FF0000") |
| ANSI index | 196 |
Available styles
bold, italic, underline, strikethrough. Combine with +: "bold+italic".
License
MIT
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
pintar-0.7.3.tar.gz
(18.2 kB
view details)
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
pintar-0.7.3-py3-none-any.whl
(20.9 kB
view details)
File details
Details for the file pintar-0.7.3.tar.gz.
File metadata
- Download URL: pintar-0.7.3.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21bf359fa3dac615e350c4cce1c25518b237aab2c843650bf0937f3729ae98bb
|
|
| MD5 |
f5046655f73142c24e7f3bc689c944f8
|
|
| BLAKE2b-256 |
00052dbd62b5ef25826ed8ceefbce29fb7f6b2ab53e047f54b7763f99f2a5211
|
File details
Details for the file pintar-0.7.3-py3-none-any.whl.
File metadata
- Download URL: pintar-0.7.3-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2717b0c6700345e1b36f8acac329ec087023ffae3cb4db8d542264eacb6a091
|
|
| MD5 |
9d245959da6487c29a400207cef7823e
|
|
| BLAKE2b-256 |
86720b960cb69be3f07c224e8dacf4a524819b9a436ae6e4c95792d1b80cb824
|