Declarative Terminal User Interface Library
Project description
:~^:. :YJ?! .Y&J?^
%@@P! :GG&! ~@@&: .PGP? B@&~.
!@@% :&@J ^@@? .#@B. G@# ^!.
!@@% !^ :&@? ^@@? #@G :%~~~~~~~~~~~~~~^B@#~^~~~~~~~~~Y@@#Y^
~?!!!J@@Y~Y&&P^.&@&~!!!?&@&!!!!!&@B :!!~~~~~~~~~~~~~~B@&~~~~~~~~~~~~~~~!^
:~^:^::::%Y?%~.:@@J::::::::::::^PBY G@#
:& &@@?:.:%%: .. .... ^PG?: G@# .?~
PG B@& JJ%%%%%%?B#G?%%%%%J&&&J: ^?!!~~~~~~~~~~B@&!~~~~~~~%B@@B%.
~@P :@&: %@B^ .!~^^^^^^^^^P@@@&G!^^^^^^^^^^^~.
.#@? ?@J :&?^:::^#&:.:..::::JP?^ :G@G#@#~P%
P@G G#. .&@P!!%#@Y!!Y&#%!!%@@&% .Y@&? G@# :PB!
Y@! ^&~ ::.#@J .&@% !@&. #@% .J&&J. G@#. %##J:
.. YB%??!..#@J .#@% %@&. .#@% ^Y#B%. G@#. .?#@G?^.
.^!?&GGJ!: .#@J .#@% %@&. .#@% .%PBY^ B@#. .%G@@#PJ!~^.
.P&&#&%^ .&@J .&@% %@&: #@% .~J&J~ B@#. ^JB@@@#J^
~#! :&@J .&@? ?@@^~!%&@% ^?!^ .#@&. :!J^
:#&? ?J^ ^J?..:P#P! B@#:
^GGGGGG^ %P~ .. %P! ?P^ ?Y~ .Y&: ?P^ ?GGGGGG:. ^YPPJ^ .&Y %P~
.~!@@%~: .&@G B@@~ P@! G@L: Y@@~ :@@P ^~&G&~^ !@B~!&@^ :B&. &B%
#&. J@%@~ B@@#.&@! G@@A /@@@~ Y@@%. Y@% !@G^. ^/ :B#. &B%
.#&: .&!^&G B@Y&.P@! G@#B@&PG@~ :@<^G% Y@% \&BBG% :B#. &B%
.#&: J@! #@~ B@!!@@@! G@^\J@^G@~ Y@! &@: Y@% .: .B@~ :B# &B%
.&@: .&&%%?@G B@% J@@! G@~ ^/ G@~ :@#%^J@% Y@% %@P~~J@^ .#B%~B@~
.PP. !B? &G: ?B~ &G~ YG^ YG^ %B% &P. !B? %PBG&~ :YGBP!
About
Declarative TUI (Terminal User Interface) library, with layout features modelled after modern web components.
Widget objects can be created by defining a class that inherits from the desired widget class.
For example, 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")
Tanmatsu supports either style. The declarative syntax should be familiar with anyone who's used Django models before.
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()
Installation
pip install tanmatsu
Documentation
https://tanmatsu.readthedocs.io/en/latest/
Requirements
- Python >=3.11
- GNU/Linux
- Full-featured terminal emulator (e.g., Gnome VTE)
- A font with unicode symbols (e.g., Noto)
Dependencies
- tri.declarative
- parsy
- wcwidth
Development dependancies:
- sphinx
Development
Installing
- If not running python 3.11, install pyenv.
- Install poetry.
- Run
poetry installfrom the repository directory to set up a virtual environment with the necessary python version and packages
Running
poetry run python3 main.py
Testing
poetry run python3 -m unittest
Changelog
See CHANGELOG.md.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tanmatsu-0.1.1.tar.gz.
File metadata
- Download URL: tanmatsu-0.1.1.tar.gz
- Upload date:
- Size: 35.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.11.0b5 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e8111432c3aecd5fe315900a97e6ca0f3285e735c4bddf975ff3237f62d151c
|
|
| MD5 |
00ad88b94a5e278adc42c9e516508d50
|
|
| BLAKE2b-256 |
02af6d78fd2735bd293c9804ae29b33520b8cdaab023d9f9b99db7d2fc1bd786
|
File details
Details for the file tanmatsu-0.1.1-py3-none-any.whl.
File metadata
- Download URL: tanmatsu-0.1.1-py3-none-any.whl
- Upload date:
- Size: 41.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.11.0b5 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62cfcfaef81482bd0f359258079004b6e92fda08fdac360b5cca63a7f0813404
|
|
| MD5 |
a2a9aaada9a5c6a378f2326b365cf4c8
|
|
| BLAKE2b-256 |
40f892467567e8f678ca456b1690fec8e8c6bad08cf6087593069c840c82902c
|