A WIP procedurally generated TUI made in NCurses using Python for CCSM
Project description
Curses UI
An easy-to-use procedurally-generated widget system for curses in Python.
Item Format
The format used across the majority of all widgets in this system.
clarification
An "arg," from here on out, is a key-value pair, from within a dictionary, that is itself a value of a key-value pair from within the dictionary passed to dict_ui
A sub arg is an arg that is only passed with a certain functionality
Every arg besides functionality that is not already a dict alone, is a dict with the key "value" pointing to your expected value, to allow for interior mutability by outside functions
global args
These arguments will be on every item, optionally unless stated otherwise.
functionality: strrequired - the functionality of the item, valid values will be covered later. Example:"functionality": "none". Program will most likely panic if not provided.description: dict[str, str]- a description of the option. Example :"description": {"value": "description"}. No description is displayed if not provided.always_show_description: dict[str, bool]- whether or not to always show the description of the item, if set toFalse, the description will only be shown while the item is selected. Example:"always_show_description": {"value": True}. Defaults to Falseexit_after_action: dict[str, bool]- whether or not to exit the current menu after the functionality has completed. Example:"exit_after_action": {"value": True}. Defaults to False
dict_ui
Arguments:
base_window: curses.window- a curses windowdictionary: dict- a dictionary following a specific format. This is what the UI is generated fromitem_display: Callable[[tuple[str, dict], bool], tuple[str, int]]- an optional keyword argument that allows users to overwrite the way items are listed. Seedefault_item_displayinui_forge.common.
functionalities
-
nonedisplays the value without doing anything apon selection, unless a global argument causes it to (exit_after_action, for example) -
run_functionruns a functionsub args:
function: dict[str, Callable[[Unknown], None]]- a reference to the function to run. Example:"function": {"value": lambda x,y=1 : x+y}args: dict[str, list]- a list of positional arguments to pass to the function. Example:"args": {"value": [1]}kwargs: dict- a dictionary of keyword arguments to pass to the function. Example:"kwargs": {"y": 2}
-
editopens the editor widget for an assigned valuesub args:
value: dict[str, str]- the value assigned before editing - this gets overwritten after a successful edit. Example:"value": {"value": "a"}validator: dict[str, Callable[[str], bool]]- a reference to a function. The input is the entire submitted string, and the output will determine whether or not it will get accepted. If it does not get accepted, the input box will be reset to the previous value, and the user will be prompted to input again. This will repeat until the uset inputs a valid value. Example:"validator": {"value": lambda x : x}allowed_human_readable: dict[str, str]- a string that gets printed after the name of the value the user is editing. This is intended to instruct users in an understandable fashion what values are valid or invalid. Example:"allowed_human_readable": {"value": "only integers allowed"}
-
selectopens the selection widgetsub args:
value: dict[str, str]- the value assigned before editing - this gets overwritten when the user selects a new value. Example:"value": {"value": "a"}options: dict- a dictionary containing dictionaries with theoptionfunctionality. Example:"options": {"a": {"functionality": "option"}, "b": {"functionality": "option"}, "c": {"functionality": "option"}}
-
optionan option in a selection menu. Only intended to be used within the selection widget. The key is the value that will be selected. -
sub menua new instance ofdict_uiwith the input dictionarysub args:
menu: dict: a menu dictionary. equivalent to anything passed todict_ui
selection_ui
Arguments:
base_window: curses.window- a curses windowoptions: dict- a dictionary containingoptionitemsitem_display: Callable[[tuple[str, dict], bool], tuple[str, int]]- an optional keyword argument that allows users to overwrite the way items are listed
editor_ui
base_window: curses.window- a curses windowname: str- the "name" of the value being assigned, ususally analagous to the name of the variable being assigned to. This gets displayed to the uservalue: str- the default value before modificationvalidator: Callable[[str], bool]- a reference to a function. The input is the entire submitted string, and the output will determine whether or not it will get accepted. If it does not get accepted, the input box will be reset to the previous value, and the user will be prompted to input again. This will repeat until the uset inputs a valid value.allowed_human_readable: str- a string that gets printed after the name of the value the user is editing. This is intended to instruct users in an understandable fashion what values are valid or invalid.
Project details
Release history Release notifications | RSS feed
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 ui_forge-1.1.0.tar.gz.
File metadata
- Download URL: ui_forge-1.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.10.10-zen1-1-zen
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c52156e6772edc544aeff750c8658a61ed0c6a7833773ba7ae7b11911809d49
|
|
| MD5 |
4c5344b33839a490131ad2bfa8585ce2
|
|
| BLAKE2b-256 |
9da3646120d9b54d34a25856f220314a6f599636ce7f258a5d965043456c6782
|
File details
Details for the file ui_forge-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ui_forge-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.10.10-zen1-1-zen
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2415095c54431bf4207b01eb0bd5fecdc9585637dd9f1639d6edc9b3d0a57e52
|
|
| MD5 |
f63449eb0e3ff62c4af5aff8d2927b66
|
|
| BLAKE2b-256 |
c0ba495da653c71b5510a6db8969b9244f63f8e23ab8ce1f34ab7a878fa095bd
|