Skip to main content

A TUI framework based on the idea of "multi-layered transparency" composition.

Project description

PRISMA TUI

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 TUI Logo
Prisma, the cat, as rendered by prismatui.

QuickStart

Run Demo

pip install prismatui
python3 demos/layouts.py

Code Example

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()

Demos

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prismatui-0.3.2.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prismatui-0.3.2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file prismatui-0.3.2.tar.gz.

File metadata

  • Download URL: prismatui-0.3.2.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for prismatui-0.3.2.tar.gz
Algorithm Hash digest
SHA256 c24a7c82688e2d0b9aed27f8de07f15d53700ba7796b89f087848c338143669d
MD5 c253bf4044f97290e5ee67cae19070f1
BLAKE2b-256 1473e5ec6e1b812ce66bc453b549363d5b529e5b57cff46471968a7570798061

See more details on using hashes here.

File details

Details for the file prismatui-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: prismatui-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for prismatui-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a306611883daae03c14424519f342ea873964c44e7d8181c8f4f00aba67cf0e3
MD5 114a1775552fb41c2b3b5e23134196c8
BLAKE2b-256 3dae0d38ce2a56d1151ae3d18b6d548757ea70e7505be7da0c6c78ad05a639e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page