A terminal UI for the la(z)yperson
Project description
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 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lazytui-0.0.3.tar.gz
(7.1 kB
view hashes)