All Projects → jquast → blessed

jquast / blessed

Licence: MIT license
Blessed is an easy, practical library for making python terminal apps

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to blessed

Asciimatics
A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Stars: ✭ 2,869 (+249.88%)
Mutual labels:  curses
lcurses
Lua bindings for Curses
Stars: ✭ 60 (-92.68%)
Mutual labels:  curses
cxxcurses
Header only ncurses wrapper
Stars: ✭ 24 (-97.07%)
Mutual labels:  curses
Taizen
curses based mediawiki browser
Stars: ✭ 249 (-69.63%)
Mutual labels:  curses
nuber
terminal epub reader with inline images
Stars: ✭ 73 (-91.1%)
Mutual labels:  curses
cpyvke
cpyvke is a variable explorer and a kernel manager written in Python 3 curses for iPython kernels (Python 2.x or 3.x)
Stars: ✭ 28 (-96.59%)
Mutual labels:  curses
Musikcube
a cross-platform, terminal-based music player, audio engine, metadata indexer, and server in c++
Stars: ✭ 2,663 (+224.76%)
Mutual labels:  curses
AbsTK
The Abstract Toolkit – a widget toolkit for GUI and text-mode applications.
Stars: ✭ 67 (-91.83%)
Mutual labels:  curses
dopewars
Game simulating the life of a drug dealer in New York
Stars: ✭ 47 (-94.27%)
Mutual labels:  curses
pybart
Real time BART (Bay Area Rapid Transit) information in your terminal!
Stars: ✭ 17 (-97.93%)
Mutual labels:  curses
Zsh Navigation Tools
Curses-based tools for Zsh, e.g. multi-word history searcher
Stars: ✭ 249 (-69.63%)
Mutual labels:  curses
git-tui
Collection of human friendly terminal interface for git.
Stars: ✭ 95 (-88.41%)
Mutual labels:  curses
deltachat-cursed
[WIP] Cursed Delta, a lightweight Delta Chat client for the command line
Stars: ✭ 33 (-95.98%)
Mutual labels:  curses
Curses
Ruby binding for curses, ncurses, and PDCurses. Formerly part of the ruby standard library.
Stars: ✭ 245 (-70.12%)
Mutual labels:  curses
termchat
Chat through the terminal with hack.chat
Stars: ✭ 30 (-96.34%)
Mutual labels:  curses
Mitype
Typing speed test in terminal
Stars: ✭ 241 (-70.61%)
Mutual labels:  curses
ncurses
Ncurses bindings for Crystal
Stars: ✭ 20 (-97.56%)
Mutual labels:  curses
GameOfLife
Conway's Game of Life
Stars: ✭ 18 (-97.8%)
Mutual labels:  curses
ngp
Ncurses code parsing tool
Stars: ✭ 52 (-93.66%)
Mutual labels:  curses
sshch
Ssh connection manager
Stars: ✭ 88 (-89.27%)
Mutual labels:  curses

Introduction

Blessed is an easy, practical library for making terminal apps, by providing an elegant, well-documented interface to Colors, Keyboard input, and screen position and Location capabilities.

from blessed import Terminal

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():
    inp = term.inkey()

print(term.move_down(2) + 'You pressed ' + term.bold(repr(inp)))
Animation of running the code example

It's meant to be fun and easy, to do basic terminal graphics and styling with Python using blessed. Terminal is the only class you need to import and the only object you should need for Terminal capabilities.

Whether you want to improve CLI apps with colors, or make fullscreen applications or games, blessed should help get you started quickly. Your users will love it because it works on Windows, Mac, and Linux, and you will love it because it has plenty of documentation and examples!

Full documentation at https://blessed.readthedocs.io/en/latest/

Examples

Animations of x11-colorpicker.py, bounce.py, worms.py, and plasma.py

x11-colorpicker.py, bounce.py, worms.py, and plasma.py, from our repository.

Exemplary 3rd-party examples which use blessed,

Screenshot of 'Voltron' (By the author of Voltron, from their README).

Voltron is an extensible debugger UI toolkit written in Python

Animation of 'cursewords' (By the author of cursewords, from their README).

cursewords is "graphical" command line program for solving crossword puzzles in the terminal.

Animation of 'githeat.interactive', using blessed repository at the time of capture.

GitHeat builds an interactive heatmap of git history.

Animations from 'Dashing' (By the author of Dashing, from their README)

Dashing is a library to quickly create terminal-based dashboards.

Animations from 'Enlighten' (By the author of Enlighten, from their README)

Enlighten is a console progress bar library that allows simultaneous output without redirection.

Demonstration of 'macht', a 2048 clone

macht is a clone of the (briefly popular) puzzle game, 2048.

Requirements

Blessed works with Windows, Mac, Linux, and BSD's, on Python 2.7, 3.4, 3.5, 3.6, 3.7, and 3.8.

Brief Overview

Blessed is more than just a Python wrapper around curses:

  • Styles, Colors, and maybe a little positioning without necessarily clearing the whole screen first.
  • Works great with Python's new f-strings or any other kind of string formatting.
  • Provides up-to-the-moment Location and terminal height and width, so you can respond to terminal size changes.
  • Avoids making a mess if the output gets piped to a non-terminal, you can output sequences to any file-like object such as StringIO, files, pipes or sockets.
  • Uses terminfo(5) so it works with any terminal type and capability: No more C-like calls to tigetstr and tparm.
  • Non-obtrusive calls to only the capabilities database ensures that you are free to mix and match with calls to any other curses application code or library you like.
  • Provides context managers Terminal.fullscreen() and Terminal.hidden_cursor() to safely express terminal modes, curses development will no longer fudge up your shell.
  • Act intelligently when somebody redirects your output to a file, omitting all of the special sequences colors, but still containing all of the text.

Blessed is a fork of blessings, which does all of the same above with the same API, as well as following enhancements:

Before And After

With the built-in curses module, this is how you would typically print some underlined text at the bottom of the screen:

from curses import tigetstr, setupterm, tparm
from fcntl import ioctl
from os import isatty
import struct
import sys
from termios import TIOCGWINSZ

# If we want to tolerate having our output piped to other commands or
# files without crashing, we need to do all this branching:
if hasattr(sys.stdout, 'fileno') and isatty(sys.stdout.fileno()):
    setupterm()
    sc = tigetstr('sc')
    cup = tigetstr('cup')
    rc = tigetstr('rc')
    underline = tigetstr('smul')
    normal = tigetstr('sgr0')
else:
    sc = cup = rc = underline = normal = ''

# Save cursor position.
print(sc)

if cup:
    # tigetnum('lines') doesn't always update promptly, hence this:
    height = struct.unpack('hhhh', ioctl(0, TIOCGWINSZ, '\000' * 8))[0]

    # Move cursor to bottom.
    print(tparm(cup, height - 1, 0))

print('This is {under}underlined{normal}!'
      .format(under=underline, normal=normal))

# Restore cursor position.
print(rc)

The same program with Blessed is simply:

from blessed import Terminal

term = Terminal()
with term.location(0, term.height - 1):
    print('This is ' + term.underline('underlined') + '!', end='')
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].