Skip to main content

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


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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lazytui-0.0.3-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file lazytui-0.0.3.tar.gz.

File metadata

  • Download URL: lazytui-0.0.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for lazytui-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ae588109fa5e11ef72bcb6ba4c0b1c356479a3efe636a9327d3dd1a650b68915
MD5 8394d44b8152388864d13c19da54418e
BLAKE2b-256 4c2eed703908391fd7894af23dcf2a64d5bdb1a44d9321fac36b406bdeeb7d90

See more details on using hashes here.

File details

Details for the file lazytui-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: lazytui-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for lazytui-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f1622071e4a8e81d24c213db24a0b1e42b744ce5e8122fbb9968592df545a485
MD5 d4ce69ed83392f22ef27559501ef5a32
BLAKE2b-256 0833db7255c8d0c74094c8ca0a59642c8a6bb21d3881c3ace7e57eeb74919077

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page