Declarative Terminal User Interface Library
Project description
About
Declarative TUI (Terminal User Interface) library, with layout features modelled after modern web components.
The syntax will be familiar with anyone who's used Django models before. Widget objects can be created declaratively by creating a class that inherits from the desired widget class.
A CSS flexbox-style widget that contains a text box and a button can be created declaratively, like so:
class NiceFlexBox(widgets.FlexBox):
text_box = widgets.TextBox(text="Hello World!")
button = widgets.Button(label="Button 2", callback=None)
class Meta:
border_label = "Nice FlexBox"
nice_flex_box = NiceFlexBox()
or imperatively, like so:
children = {
'text_box': widgets.TextBox(text="Hello World!"),
'button': widgets.Button(label="Button 2", callback=None)
}
nice_flex_box = widgets.FlexBox(children=children, border_label="Nice FlexBox")
Example
which is given by the code:
from tanmatsu import Tanmatsu, widgets
class ButtonList(widgets.List):
class Meta:
border_label = "List"
children = [
widgets.Button(label="Button 1", callback=None),
widgets.Button(label="Button 2", callback=None),
widgets.Button(label="Button 3", callback=None),
]
item_height = 5
class VertSplit(widgets.FlexBox):
text_box = widgets.TextBox(border_label="Text Box", text="Hello World!")
text_log = widgets.TextLog(border_label="Text Log")
button_list = ButtonList()
class Meta:
flex_direction = widgets.FlexBox.HORIZONTAL
with Tanmatsu(title="Tanmatsu!") as t:
rw = VertSplit()
t.set_root_widget(rw)
for (i, v) in enumerate(rw.button_list.children):
v.callback = lambda i=i: rw.text_log.append_line(f"Button {i + 1} pressed")
t.loop()
Documentation
https://tanmatsu.readthedocs.io/en/latest/
Requirements
- Python >=3.11
- GNU/Linux
- Full-featured terminal emulator (e.g., Gnome VTE)
Dependencies
- tri.declarative
- parsy
- sphinx
- wcwidth
Development
Installing
- Install pyenv (intructions in the
README.md
) - Install pipenv with
pip3 install pipenv
- Run
pipenv install
from the repository directory to set up a virtual environment with the necessary python version and packages
Running
pipenv run python3 main.py
Testing
pipenv run python3 -m unittest
License
MIT. For more information, see LICENSE.md
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
tanmatsu-0.0.1.1.tar.gz
(32.6 kB
view hashes)
Built Distribution
tanmatsu-0.0.1.1-py3-none-any.whl
(39.4 kB
view hashes)
Close
Hashes for tanmatsu-0.0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1b0b36c208babeb75f53c8becfb89e2df600fcec19902e585abc02276a52140 |
|
MD5 | 60b4ce229b566c870f1188e9c9edecc3 |
|
BLAKE2b-256 | 5096ec222583ee87e1fcd0e3136a77ec25442bbcee2d0bf31dc7172685690ffe |