A terminal UI for the la(z)yperson
import lazytui
from lazytui.fmt import fmt
class Hello(lazytui.TUI):
def setup(self):
self.enable_title_bar('hello world', style="underline")
self.enable_status_bar('press q to quit', fg="magenta")
def draw(self):
self.write(2, 0, 'hello world ' + fmt('from lazytui', fg="blue", bg="white", style=["underline", "bold"]))
def key_pressed(self, key):
if key == 'q':
self.exit()
Hello().run()
Lazytui is a python UI framework built around the built-in curses module. It is simple to set up, easy to use and comes with all the built in power of the curses framework.
Installation
pip install lazytui
Design
Lazytui design is based off of the design philosophy of Processing/P5js. The TUI triggers certain methods that the user can override to control the flow of the program.
| Event Method | Description |
|---|---|
setup(self) |
After __init__() is called but before we itereate over the draw() loop |
draw(self) |
Continuously executes the lines of code contained inside its block until the program is stopped. |
key_pressed(self, key) |
Function called when user presses a key. Key is given as a string as an argument. |
window_resized(self) |
Function called when the window is resized. |
cleanup(self) |
Called at the very end of the programs execution, right before it exits. |
Helper methods
| Method | Description |
|---|---|
self.get_width() |
Returns the number of columns of the terminal. |
self.get_height() |
Returns the number of rows of the terminal. |
self.write() |
Write formatted text to the terminal. |
Colors
See curses constants documentation
FG/BG colors
| Color | Curses equivalent |
|---|---|
"black" |
curses.COLOR_BLACK |
"blue" |
curses.COLOR_BLUE |
"cyan" |
curses.COLOR_CYAN |
"green" |
curses.COLOR_GREEN |
"magenta" |
curses.COLOR_MAGENTA |
"red" |
curses.COLOR_RED |
"white" |
curses.COLOR_WHITE |
"yellow" |
curses.COLOR_YELLOW |
Styles
| Style | Curses equivalent |
|---|---|
"altcharset" |
curses.A_ALTCHARSET |
"blink" |
curses.A_BLINK |
"bold" |
curses.A_BOLD |
"dim" |
curses.A_DIM |
"invis" |
curses.A_INVIS |
"italic" |
curses.A_ITALIC |
"normal" |
curses.A_NORMAL |
"protect" |
curses.A_PROTECT |
"reverse" |
curses.A_REVERSE |
"standout" |
curses.A_STANDOUT |
"underline" |
curses.A_UNDERLINE |
"horizontal" |
curses.A_HORIZONTAL |
"left" |
curses.A_LEFT |
"low" |
curses.A_LOW |
"right" |
curses.A_RIGHT |
"top" |
curses.A_TOP |
"vertical" |
curses.A_VERTICAL |
"chartext" |
curses.A_CHARTEXT |
Metadata
Release files for lazytui 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lazytui-0.0.3.tar.gz | 7.1 kB | Without provenance | Details for lazytui-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lazytui-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for lazytui-0.0.3-py3-none-any.whl |
Total release size: 15.4 kB
Release files / lazytui-0.0.3.tar.gz
| Download URL | lazytui-0.0.3.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae588109fa5e11ef72bcb6ba4c0b1c356479a3efe636a9327d3dd1a650b68915
|
|
BLAKE2b-256 checksum How to use checksums |
4c2eed703908391fd7894af23dcf2a64d5bdb1a44d9321fac36b406bdeeb7d90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0
|
Release files / lazytui-0.0.3-py3-none-any.whl
| Download URL | lazytui-0.0.3-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1622071e4a8e81d24c213db24a0b1e42b744ce5e8122fbb9968592df545a485
|
|
BLAKE2b-256 checksum How to use checksums |
0833db7255c8d0c74094c8ca0a59642c8a6bb21d3881c3ace7e57eeb74919077
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0
|
Security for lazytui 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.