Skip to main content

🎨 dcolor

Python 3.8+ License MIT Status

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 palette196 (0-255)
  • 🏷️ named colors"red", "cyan", "orange"...
  • 🎭 background colorsbg="#ff0000"
  • stylesbold, 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

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dcolor_drawiks-0.3.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dcolor_drawiks-0.3.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file dcolor_drawiks-0.3.0.tar.gz.

File metadata

  • Download URL: dcolor_drawiks-0.3.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for dcolor_drawiks-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eb87d24905014b51cde7a26bb80b3c8a92c1300e418290ffa4a78965e3e73bf0
MD5 afa35f2f8dcdb6f7d4201e1241b75795
BLAKE2b-256 c29e92edebf7b54b696edbc45bb01777a0182bc33c82ed5e1c06da45ab200475

See more details on using hashes here.

File details

Details for the file dcolor_drawiks-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: dcolor_drawiks-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for dcolor_drawiks-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6865364dcfc310dfcbd39ec5d8413bd387c1a4d01a1c005dd49dcbf804440c9a
MD5 ec1cbb2b65b098a7d318fb82566bca6d
BLAKE2b-256 c8dab7658ee2ccbdaef3ad9352bf691391f6d51fec577ef7f099b82c718c86d3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page