🎨 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
- 🪟 Windows — native Windows 10+ support (no dependencies)
- 🚫 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
on Windows 10+ (Build 10586+) works natively. on older Windows versions, escape codes render as garbage.
💡 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
Metadata
Release files for dcolor-drawiks 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dcolor_drawiks-0.3.0.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dcolor_drawiks-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / dcolor_drawiks-0.3.0.tar.gz
| Download URL | dcolor_drawiks-0.3.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb87d24905014b51cde7a26bb80b3c8a92c1300e418290ffa4a78965e3e73bf0
|
|
BLAKE2b-256 checksum How to use checksums |
c29e92edebf7b54b696edbc45bb01777a0182bc33c82ed5e1c06da45ab200475
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / dcolor_drawiks-0.3.0-py3-none-any.whl
| Download URL | dcolor_drawiks-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6865364dcfc310dfcbd39ec5d8413bd387c1a4d01a1c005dd49dcbf804440c9a
|
|
BLAKE2b-256 checksum How to use checksums |
c8dab7658ee2ccbdaef3ad9352bf691391f6d51fec577ef7f099b82c718c86d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|