Skip to main content

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

    Keybinds

    You can set the Menu's keybinds by passing in a keybinds list:

    my_menu = tui.Menu(stdscr, 
                       [("Hello", tui.nothing), ("Quit", quit_app)], 
                       [([curses.KEY_UP, ord("W"), ord("w")], tui.Menu.move_up),
                        ([curses.KEY_DOWN, ord("S"), ord("s")], tui.Menu.move_down),
                        ([10], tui.Menu.select) # (10 = Enter key)
                       ]
                    )
    

    The default keybindings are:

    [
        ([curses.KEY_UP], tui.Menu.move_up),
        ([curses.KEY_DOWN], tui.Menu.move_down),
        ([10, curses.KEY_RIGHT], tui.Menu.select),
        ([curses.KEY_BACKSPACE, curses.KEY_LEFT], tui.Menu.back)
    ]
    

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

Metadata

Release files for boxes-tui 2.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boxes-tui 2.2.1
File Size Uploaded
boxes_tui-2.2.1.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for boxes-tui 2.2.1
File Interpreter ABI Platform
boxes_tui-2.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / boxes_tui-2.2.1.tar.gz

Download URL boxes_tui-2.2.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fbb7986a7534bc95c9a594c99e77b714d340590d705ce1ae5651635f3babce1f
BLAKE2b-256 checksum
How to use checksums
4556a59990274ce82905c9d11a0576a89c08eb948bba48c180939a72503bb9f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2025.

Transparency log

Release files / boxes_tui-2.2.1-py3-none-any.whl

Download URL boxes_tui-2.2.1-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f432a751dca9c3ae249853d90000aeb0366983777164619f14cb2260d66e9647
BLAKE2b-256 checksum
How to use checksums
f2a8e68776e3a6b103433352bc5b4c54c04559fd0f01f0e168a96496a0101293
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2.2.1 This release

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page