dcolor by drawiks
Project description
🎨 dcolor
dcolor — colored terminal output with hex/rgb support
(─‿‿─)
____
/ __ \ ______ ____ / /____ _____
/ / / // ____// __ \ / // __ \/ ___/
/ /_/ // /____/ /_/ // // /_/ / /
/_____/ \____/ \____//_/ \____/_/
📦 installation
pip install dcolor-drawiks
📑 quick start
from dcolor import color
print(color("hello!", "#ff0000"))
print(color("hello!", (255, 0, 0)))
print(color("hello!", "red"))
print(color("hello!", "#ff0000", "bold", "underline"))
🧩 features
- 🎨 hex colors —
"#ff0000"or"#f00" - 🌈 rgb colors —
(255, 0, 0) - 🔢 256-color palette —
196(0-255) - 🏷️ named colors —
"red","cyan","orange"... - 🎭 background colors —
bg="#ff0000" - ✨ styles —
bold,italic,underline,strike,dim,blink - 📱 auto terminal detection — no colors in piped output
- 🚫 no dependencies — stdlib only
📖 usage
hex color
from dcolor import color
print(color("error", "#ff0000"))
print(color("success", "#00ff00"))
print(color("info", "#3b82f6"))
short hex also works:
print(color("text", "#f00")) # same as #ff0000
rgb color
print(color("text", (255, 165, 0)))
256-color palette
print(color("text", 196)) # orange
print(color("text", fg=196, bg=21)) # orange on blue
colors 0-255 supported (see 256 terminal colors)
named colors
print(color("text", "red"))
print(color("text", "cyan"))
print(color("text", "orange"))
available names: black, red, green, yellow, blue, magenta, cyan, white, grey, orange, pink, purple, brown, lime, teal
styles
print(color("text", "red", "bold"))
print(color("text", "#ff0000", "bold", "underline"))
print(color("text", "cyan", "italic", "strike"))
available styles: bold, dim, italic, underline, blink, strike
background color
print(color("text", fg="#ffffff", bg="#ff0000")) # white on red
print(color("text", bg="#00ff00")) # background only
style only (no color)
print(color("text", None, "bold"))
print(color("text", None, "underline", "italic"))
strip ansi codes
from dcolor import strip
raw = color("hello", "#ff0000", "bold")
clean = strip(raw) # "hello"
auto terminal detection
by default dcolor doesn't color output if it's piped or redirected:
python script.py > log.txt # no colors
python script.py | cat # no colors
python script.py # colors (in terminal)
force colors on:
print(color("text", "#ff0000", force=True)) # always colored
💡 examples
from dcolor import color
print(color("[ERROR]", "#ff4444", "bold"), "something went wrong")
print(color("[SUCCESS]", "#44ff44", "bold"), "everything is fine")
print(color("[WARN]", "#ffaa00", "bold"), "watch out")
print(color("[INFO]", "#888888"), "just fyi")
use in dlogger
from dlogger import logger
from dcolor import color
logger.info(color("payment received", "#44ff44", "bold"))
logger.error(color("connection failed", "#ff4444"))
📜 license
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 dcolor_drawiks-0.2.0.tar.gz.
File metadata
- Download URL: dcolor_drawiks-0.2.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e44bd60ef7b27b6866307106df1ac03dbd85a7f1a061c306d2f7261900c3f6f5
|
|
| MD5 |
237549440d325cad3d3e0ed79bd073db
|
|
| BLAKE2b-256 |
1d58e70650c81e3840b3349d780d5d17944628e44479e030b7a6dc615a03b7f0
|
File details
Details for the file dcolor_drawiks-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dcolor_drawiks-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78f99581ff88f8c1b719464308c45fd40c6ecaa415e1df654ad2728e8a83a5d5
|
|
| MD5 |
62b156be1d887573b15062416eb3d2a4
|
|
| BLAKE2b-256 |
388ea5efd1fcfb99463af79ae0819646189347a1937e311e2f7c97c7b15e008a
|