Curses-like terminal wrapper, with colored strings!
Curtsies is a Python 2.7 & 3.4+ compatible library for interacting with the terminal. This is what using (nearly every feature of) curtsies looks like:
import random from curtsies import FullscreenWindow, Input, FSArray from curtsies.fmtfuncs import red, bold, green, on_blue, yellow print(yellow('this prints normally, not to the alternate screen')) with FullscreenWindow() as window: with Input() as input_generator: msg = red(on_blue(bold('Press escape to exit'))) a = FSArray(window.height, window.width) a[0:1, 0:msg.width] = [msg] for c in input_generator: if c == '<ESC>': break elif c == '<SPACE>': a = FSArray(window.height, window.width) else: s = repr(c).decode() row = random.choice(range(window.height)) column = random.choice(range(window.width-len(s))) color = random.choice([red, green, on_blue, yellow]) a[row, column:column+len(s)] = [color(s)] window.render_to_terminal(a)
Paste it in a
something.py file and try it out!
pip install curtsies
FSArray objects contain multiple such strings with each formatted string on its own row, and FSArray objects can be superimposed on each other to build complex grids of colored and styled characters through composition.
(the import statement shown below is outdated)
Such grids of characters can be rendered to the terminal in alternate screen mode
(no history, like
top etc.) by FullscreenWindow objects
or normal history-preserving screen by CursorAwareWindow objects.
User keyboard input events like pressing the up arrow key are detected by an
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size curtsies-0.3.4-py2.py3-none-any.whl (35.0 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size curtsies-0.3.4.tar.gz (52.7 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for curtsies-0.3.4-py2.py3-none-any.whl