Blessed

1.38.0 · active · verified Mon Apr 06

Blessed is an easy, practical Python library for making terminal applications, offering an elegant interface to handle colors, keyboard input, and screen positioning. It is currently at version 1.38.0 and maintains an active development and release cadence, with frequent updates improving compatibility and adding features.

Warnings

Install

Imports

Quickstart

This example initializes the terminal, clears the screen, centers a styled message, waits for a single key press using a context manager for `cbreak` mode and a hidden cursor, then prints the pressed key before exiting. The `timeout` for `inkey` uses an environment variable fallback for robustness.

from blessed import Terminal
import os

term = Terminal()
print(term.home + term.clear + term.move_y(term.height // 2))
print(term.black_on_darkkhaki(term.center('press any key to continue.')))

with term.cbreak(), term.hidden_cursor():
    # Use os.environ.get for auth keys in real applications if needed
    inp = term.inkey(timeout=os.environ.get('BLESSED_INKEY_TIMEOUT', 3))

print(term.move_down(2) + 'You pressed ' + term.bold(repr(inp)))
print(term.normal + 'Exiting.')

view raw JSON →