A collection of tools for python TUIs
Project description
Boxes
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.
-
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)
keycan 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
indexis the index of the entry the user selected. -1 if the user pressed backspace.return_of_the_functionis 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file boxes_tui-2.1.0.tar.gz.
File metadata
- Download URL: boxes_tui-2.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
852ee2aa453700f2e5abdc2cf6b426240ed461b25926f4411bad763513ddfb4c
|
|
| MD5 |
f2c1640d4302c7ec0b21c30a9457ebe9
|
|
| BLAKE2b-256 |
408c2506eedef8106f4dd3a60981d41f29a11ba6a2d41d38b3f0105639c63c2d
|
Provenance
The following attestation bundles were made for boxes_tui-2.1.0.tar.gz:
Publisher:
publish-to-pypi.yml on IamLegende7/boxes-tui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
boxes_tui-2.1.0.tar.gz -
Subject digest:
852ee2aa453700f2e5abdc2cf6b426240ed461b25926f4411bad763513ddfb4c - Sigstore transparency entry: 673043577
- Sigstore integration time:
-
Permalink:
IamLegende7/boxes-tui@9cf5fd0a0a0b4182c1cab6bfe54fd6d22b5d6257 -
Branch / Tag:
refs/tags/v2.01.1 - Owner: https://github.com/IamLegende7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@9cf5fd0a0a0b4182c1cab6bfe54fd6d22b5d6257 -
Trigger Event:
push
-
Statement type:
File details
Details for the file boxes_tui-2.1.0-py3-none-any.whl.
File metadata
- Download URL: boxes_tui-2.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dc599ca9bc6a36e258a998a139f6f81022aaca952518db967b37c8c54f8360b
|
|
| MD5 |
0c72f743414540f5a5e7a55178899153
|
|
| BLAKE2b-256 |
b6187bbf971b72132e8a4ac75abc21c71625a0fb994f601c323f42528f5f98bc
|
Provenance
The following attestation bundles were made for boxes_tui-2.1.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on IamLegende7/boxes-tui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
boxes_tui-2.1.0-py3-none-any.whl -
Subject digest:
6dc599ca9bc6a36e258a998a139f6f81022aaca952518db967b37c8c54f8360b - Sigstore transparency entry: 673043580
- Sigstore integration time:
-
Permalink:
IamLegende7/boxes-tui@9cf5fd0a0a0b4182c1cab6bfe54fd6d22b5d6257 -
Branch / Tag:
refs/tags/v2.01.1 - Owner: https://github.com/IamLegende7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@9cf5fd0a0a0b4182c1cab6bfe54fd6d22b5d6257 -
Trigger Event:
push
-
Statement type: