Blessings is a thin, practical Python wrapper around terminal capabilities, offering an elegant interface for coloring, styling, and positioning text. It aims to simplify advanced terminal interactions compared to raw ANSI escape codes or the `curses` library, handling common cases like output redirection gracefully. The latest version, 1.7, was released in June 2018. The project is largely unmaintained, with active development continuing in a fork called `blessed`.
pip install blessingsVerified import paths — ran on the pinned version, not inferred.
Initialize the Terminal object and use its attributes for styling. The `location` context manager allows temporary cursor movements. Check `term.does_styling` for graceful degradation when output is piped to a non-terminal.
Consider migrating to the `blessed` library (`pip install blessed`) for continued support and new features, especially if targeting modern Python versions or Windows.
On Windows, `blessings` needs to be used in conjunction with a library like `colorama` for native CMD support. The `blessed` fork (not `blessings`) offers native Windows support starting from its later versions.
Ensure you are running Blessings on a compatible Python version (>=2.7, excluding 3.0-3.3, and older Python 3.x versions up to 3.6 for Blessings 1.7). For Python 3.7+, you should use the `blessed` library instead.
For comprehensive keyboard input, including arrow keys and special characters, you would need to use `curses` directly or consider the `blessed` fork, which specifically added enhanced keyboard input capabilities.
Pass `force_styling=True` to the `Terminal` constructor: `term = Terminal(force_styling=True)`. Alternatively, check `term.does_styling` to conditionally apply formatting.
Use the callable form: `print(term.bold('text'))`. This automatically applies the style and resets it afterward, reducing boilerplate and potential errors.Run `pip install blessings` in your terminal to install the library.
On Windows, install the `windows-curses` package: `pip install windows-curses`. For other operating systems, ensure your system has `ncurses` development libraries installed (e.g., `libncurses-dev` on Debian/Ubuntu, `ncurses-devel` on Fedora/RHEL).
Ensure the `TERM` environment variable is set to a valid terminal type (e.g., `xterm`, `xterm-256color`, `screen`). You can set it in your shell before running the Python script: `export TERM=xterm`.
Set the `TERM` environment variable to an appropriate value for your terminal. For example, in Bash or Zsh, use `export TERM=xterm` or `export TERM=xterm-256color`. Add this to your shell's configuration file (e.g., `~/.bashrc`, `~/.zshrc`) to make it permanent.
No dependency data recorded yet.