Skip to main content

simple and robust terminal user interface library for the command line.

Project description

pytermgui

A simple module to display UI in the terminal, as well as to read input.

For now, a good example of use would be teahaz-client, but documentation will be coming soon.

getting started

# version with comments & explanation: examples/readme_example.py

from pytermgui import Container,container_from_dict,getch

data = {
    "ui__title": "Test data",
    "key": "value",
    "key2": "value2",
    "ui__button": {
        "id": "test-data_button",
        "value": "publish!"
    }
}

containers = container_from_dict(data,width=40)
c = containers[0]

c.select()
c.center()
print('\033[2J')
print(c)

# - this can be substituted for:
# from pytermgui.utils import basic_selection
# basic_selection(c)
# - but for anything more advanced than basic use
#   you should define your own method.
while True:
    key = getch()

    if key == "ARROW_UP":
        c.selected_index -= 1

    elif key == "ARROW_DOWN":
        c.selected_index += 1

    elif key == "SIGTERM":
        raise KeyboardInterrupt

    c.select()
    print(c)

readme-example

images

examples/basic_menu.py:

basic_menu

examples/project_picker.py:

project_picker

teahaz menu picker:

menu_picker

teahaz file picker:

filepicker

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

pytermgui-0.0.7.tar.gz (19.4 kB view details)

Uploaded Source

File details

Details for the file pytermgui-0.0.7.tar.gz.

File metadata

  • Download URL: pytermgui-0.0.7.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for pytermgui-0.0.7.tar.gz
Algorithm Hash digest
SHA256 a1f68f0e12da943f18cb7c2f8ea5967ac1b42b66e18be3e799c2c92c8d1dad0f
MD5 15a28004ec37af0f9de1ed886849a9da
BLAKE2b-256 bda52b3ed4357879fe3c99c1a952eb28b9edf045a8f054a49194b75413282862

See more details on using hashes here.

Supported by

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