Skip to main content

Colorful, styled terminal printing for Python

Project description

format_printing

A Python library for rich, styled terminal output — colors, gradients, tables, spinners, progress bars, and more. Works as a drop-in replacement for Python's built-in print and input.

pip install format_printing

Features

  • Colored and styled text (bold, italic, underline, strikethrough, dim)
  • Named colors, hex colors, and RGB tuples
  • Gradient text (per-character color blending)
  • Bordered boxes
  • Auto-sized tables from dicts or lists
  • Clickable terminal hyperlinks
  • Typewriter effect printing
  • Spinner animations (context manager or function-wrapping)
  • Progress bars (function-wrapping or fixed-duration)

Quick Start

from format_printing import print, print_box, print_gradient, spinner, progress_bar

Colors

Colors can be passed as:

  • A named string: "red", "cyan", "neon_pink", "gold", etc.
  • A hex string: "#ff6600"
  • An RGB tuple: (255, 100, 0)

Built-in named colors: red, orange, yellow, green, blue, indigo, violet, black, white, brown, grey / gray, cyan, magenta, neon_pink, gold, crimson


API Reference

print(*args, color, bg, bold, dim, italic, underline, strikethrough)

Drop-in replacement for the built-in print. Accepts all standard print keyword arguments.

from format_printing import print

print("Hello, world!", color="cyan", bold=True)
print("Warning!", color="#ff6600", bg="black", underline=True)
print("Soft text", dim=True)

print_type(*args, color, bg, bold, dim, italic, underline, strikethrough, delay)

Prints text character by character with a typewriter effect.

from format_printing import print_type

print_type("Loading complete.", color="green", delay=0.05)
Param Default Description
delay 0.03 Seconds between each character

input(prompt, color, bg, bold, dim, italic, underline, strikethrough)

Drop-in replacement for the built-in input with styled prompts.

from format_printing import input

name = input("Enter your name: ", color="yellow", bold=True)

clear()

Clears the terminal screen.

from format_printing import clear

clear()

print_box(*args, color, border_color, bold, dim, italic, padding)

Prints text inside a Unicode bordered box.

from format_printing import print_box

print_box("Operation complete!", color="green", border_color="cyan", padding=2)
Param Default Description
padding 1 Horizontal padding inside the box

print_gradient(*args, start, end)

Prints text with a smooth per-character color gradient.

from format_printing import print_gradient

print_gradient("Rainbow text!", start="red", end="blue")
print_gradient("Sunset vibes", start="#ff6600", end="#ffcc00")

print_dual_gradient(*args, text_start, text_end, bg_start, bg_end)

Prints text with independent gradients for both foreground and background.

from format_printing import print_dual_gradient

print_dual_gradient("Fancy!", text_start="white", text_end="yellow", bg_start="blue", bg_end="magenta")

print_table(data, border_color, header_color)

Prints an auto-sized, aligned table. Accepts a list of dicts or a list of lists (first row = headers).

from format_printing import print_table

# From dicts
data = [
    {"Name": "Alice", "Role": "Engineer", "Level": "Senior"},
    {"Name": "Bob",   "Role": "Designer", "Level": "Mid"},
]
print_table(data, border_color="grey", header_color="cyan")

# From lists
data = [
    ["Name", "Score"],
    ["Alice", "98"],
    ["Bob",   "87"],
]
print_table(data)

print_link(text, url, color, bold, underline)

Prints a clickable hyperlink (supported in most modern terminals).

from format_printing import print_link

print_link("Visit PyPI", "https://pypi.org", color="cyan", bold=True)

loading_context(message, color, done)

A context manager that shows a spinner while a block of code runs.

from format_printing import loading_context
import time

with loading_context("Fetching data", color="cyan", done="Data loaded!"):
    time.sleep(2)
Param Default Description
message "Processing" Text shown next to the spinner
color "cyan" Spinner color
done "Done!" Message shown on completion

spinner(message, fn, *args, duration, spinner_color, color, done, **kwargs)

Two modes:

Fixed duration — spins for a set number of seconds:

from format_printing import spinner

spinner("Warming up", duration=2.0, spinner_color="magenta")

Function-wrapping — spins until a function finishes, then returns its result:

from format_printing import spinner
import time

def fetch_data(url):
    time.sleep(2)
    return {"status": "ok"}

result = spinner("Fetching", fetch_data, "https://example.com", done="Fetched!")
print(result)
Param Default Description
duration 2.0 Seconds to spin (fixed mode only)
spinner_color "cyan" Color of the spinner character
color None Color of the message text
done "Done!" Completion message

progress_bar(fn, *args, message, bar_color, bracket_color, text_color, length, duration, done, **kwargs)

Two modes:

Fixed duration — fills the bar over a set number of seconds:

from format_printing import progress_bar

progress_bar(duration=3.0, message="Installing", bar_color="green")

Function-wrapping — fills the bar while a function runs:

from format_printing import progress_bar
import time

def process():
    time.sleep(3)
    return "finished"

result = progress_bar(process, message="Processing", done="Complete!")
print(result)
Param Default Description
message "Processing" Label shown next to the bar
bar_color "green" Color of the filled portion
bracket_color "grey" Color of the [ ] brackets
text_color None Color of the message text
length 20 Width of the bar in characters
duration 3.0 Seconds to fill (fixed mode only)
done "Done!" Completion message

License

MIT License — see LICENSE for details.

Project details


Download files

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

Source Distribution

format_printing-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

format_printing-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file format_printing-0.1.0.tar.gz.

File metadata

  • Download URL: format_printing-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for format_printing-0.1.0.tar.gz
Algorithm Hash digest
SHA256 07f26589662af244a6775e7eea509cf40becb9e38b9a6e1df433097166802274
MD5 783f8f25e1043b12c87cc5e5e9408eb8
BLAKE2b-256 c9f5a24339a7b1d69422465238cba131a6f57fb88335299d66fbcf7dca742c44

See more details on using hashes here.

File details

Details for the file format_printing-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for format_printing-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b92e881812d265d2825dc84a50762b7adaddc580f213d6bdc258a3adb32236b
MD5 9d7b0836b4051ca6af178b9239f5b665
BLAKE2b-256 8a138c056fcf76736f857e1bfd31d2478e0d0a11e2e867ecdaa2a016ccf5d8a3

See more details on using hashes here.

Supported by

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