Prisma TUI (Python teRminal graphIcS with Multilayered trAnsparency) is a Python framework for building composable Terminal User Interfaces (TUIs). The Terminal class serves as a wrapper for terminal backends (e.g. curses) while providing a customizable application loop. Flexible layouts can be arranged by creating a hierarchy of Section class instances. Complex displays can be composed by
Prisma is built around the idea of multilayered transparency, which consists in overlaying different "layers" of text on top of each other and merging them together to compose more complex displays (think of stacking together images with transparency). This can be achieved by using the Layer class. Prisma also provides advanced color management, allowing to write and read multi-colored layers from its own custom PAL (PALette, JSON with color pair values) and PRI (PRisma Image, binary with the chars and the respective color pairs to form an image) formats.

Prisma, the cat, as rendered by prismatui.
pip install prismatui
python3 demos/layouts.py
import prismatui as pr
class MyTUI(pr.Terminal):
def on_start(self):
pr.init_pair(1, pr.COLOR_BLACK, pr.COLOR_CYAN)
def on_update(self):
self.draw_text('c', 'c', "Hello, pr!", pr.A_BOLD)
self.draw_text("c+1", 'c', f"Key pressed: {self.key}", pr.A_BOLD)
self.draw_text('b', 'l', "Press q to exit", pr.get_color_pair(1))
def should_stop(self):
return self.key in (pr.KEY_Q_LOWER, pr.KEY_Q_UPPER)
if __name__ == "__main__":
MyTUI().run()See the demos/ folder for example applications:
images.py: Image rendered from a pair of PRI and PAL files.layouts.py: Example of a complex layout built using different Section techniques.movement.py: Example of an application in no-delay mode.keys.py: Simple "hello world" example.