Skip to content

DiegoBarMor/prismatui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors