Skip to main content

A collection of tools for python TUIs

Project description

Boxes

Python 3.9+ License: 2-Clause-BSD

Boxes is a collection of tools for making TUI python projects.

Dependencies

Boxes uses curses, with comes with python, so nothing must be installed additionally

How to use

Setup

First you will have to import the package:

from boxes_tui import TUI

Now you will need to create a new TUI object intance:

my_tui = TUI()

After that you can use the tools that this package supplies.

Curses Wrapper

It is adviced to use the curses wrapper. It supports error handling, in the case your program terminates before calling:

my_tui.cleanup()

To use the wrapper you will have to import:

from curses import wrapper
from boxes_tui import TUI

Change your main function to take in the parameter stdsrc:

def main(srdsrc):

and call it using:

wrapper(main)

You will also need to construct the TUI opject with stdsrc:

my_tui = TUI(stdsrc)

Tool usage

See example.py for a basic TUI script example.

  1. Menu

    Creation

    This simple menu is navigatable by arrow keys and enter.

    You have to pass in the lable and a function to execute; all in a list.

    Here is an example for a super basic menu:

    my_menu = tui.Menu(stdscr, [("Hello", tui.nothing), ("Quit", quit_app)])
    

    Here the entrys get stored as a list of tuples of (label, function_to_call)

    As you can see, you also put in a window. Its values (aka the origin coord and the height & width) will be used for the Menu.

    You can chage them later using:

    my_menu.chage_values(x, y, width, height)
    

    Ticking

    Ticking refreshes the menu and processes keypresses. For values it returns, see Returns

    You can tick the function using:

    my_menu.tick(key)
    

    key can be gotten by using:

    key = stdsrc.getch()
    

    Returns

    When ticking, the menu may (when the user presses "enter" or "backspace") return a tuple of (index, return_of_the_function)

    Were index is the index of the entry the user selected. -1 if the user pressed backspace.

    return_of_the_function is whatever the function may have returned, that has been called by the menu.

If you encounter any bug, optimization issue or anything else you would like me to change, please feel free to let me know :)

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

boxes_tui-2.1.3.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

boxes_tui-2.1.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file boxes_tui-2.1.3.tar.gz.

File metadata

  • Download URL: boxes_tui-2.1.3.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for boxes_tui-2.1.3.tar.gz
Algorithm Hash digest
SHA256 442a5ffe8004263376bece96ecc62370cc339d86932311e834fcc7b27bfbb5c3
MD5 abff9ac350f66e9091e52b6a8bbca33e
BLAKE2b-256 83002844ceda7c5dff3a8b877a23981ab8f74d861b4ae27cb6d6a3cf9799e13e

See more details on using hashes here.

Provenance

The following attestation bundles were made for boxes_tui-2.1.3.tar.gz:

Publisher: publish-to-pypi.yml on IamLegende7/boxes-tui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file boxes_tui-2.1.3-py3-none-any.whl.

File metadata

  • Download URL: boxes_tui-2.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for boxes_tui-2.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c11e6b3d5d366dda89b7ee4dcaf41fca566379523e156a46f4b77d82354d1bc3
MD5 653c2944e527aeb4d79711704047e804
BLAKE2b-256 2775264860fd1e70755a2da0cc7a9f79f246b860956c30163d04e9d66bc08118

See more details on using hashes here.

Provenance

The following attestation bundles were made for boxes_tui-2.1.3-py3-none-any.whl:

Publisher: publish-to-pypi.yml on IamLegende7/boxes-tui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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