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:
item format is the main format used by the majority of widgets in this system.
definitions
An "arg," from here on out, is a key-value pair, from within a dictionary, that is itself a value of a dictionary in item format
A sub arg is an arg that is only passed with a certain functionality sub args are required unless otherwise specified
global args
These arguments will be on every item listed here, optionally unless otherwise specified.
functionality: str- the functionality of the item, valid values will be covered later. Invalid values will do the same as not specifying at all.description: str- a description of the optionalways_show_description: 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.exit_after_action- exits the current menu after the option is selected and its functionality is performed. Can be used with thenonefunctionality to implement an exit button.
functionalities
-
run_functionRuns a function with arbitrary argumentsSub Args:
function: Callable[[Unknown], None]- a reference to the function to runargs: listoptional - a list of positional arguments to pass to the functionkwargs: dict[str, Unknown]optional - a dictionary of keyword arguments to pass to the function
-
editOpens the editor widget. Thenameargument of the selection widget is the key of this item.Sub Args:
value: str- as if you were passing it directly to the selection widget, format covered below. This gets overwritten after a successful edit.validator: Callable[[str], bool]optional - as if you were passing it directly to the selection widget, format covered below.allowed_human_readable: stroptional - as if you were passing it directly to the selection widget, format covered below.
-
selectOpens the selection widgetsub args:
value: str- as if you were passing it directly to the selection widget, format covered below. This gets overwritten when the user selects a new value.options: dict[str, dict]- as if you were passing it directly to the selection widget, format covered below.
-
optionOnly intended to be used with the selection widget. Provides thevaluesub arg:sub args:
value: Any- changes the returned value of the option. Useful if you want to have a different name displayed to the user than what is returned. Careful, though. In the dict ui the returned value will be displayed to the user after they select it if you don't havedisplay_valueset to False in the select item, or havedisplayed_valueset.displayed_value: stroptional - what is displayed to the user in a dict ui, rather thanvalue.
-
sub menuA new instance ofdict_uiwith the input menu dictionarySub Args:
menu: dict- a menu dictionary
dict_ui
Arguments:
base_window: curses.window- a curses windowdictionary: dict[str, dict]- a dictionary with values of dicts in item format. This is what the UI is generated from.item_display: Callable[[tuple[str, dict], bool], tuple[str, int]]optional - an argument that allows users to overwrite the way items are listedstart_line: intoptional - the line to start at in the selection. Will error if out-of-boundsstart_pos: intoptional - the amount of lines to pan down. Will error if out-of-bounds
selection_ui
Arguments:
base_window: curses.window- a curses windowoptions: dict[str, dict]- a dictionary containing dictionaries in item format. All global args are valid, and each item can optionally have theoptionfunctionality for some extra functionalityitem_display: Callable[[tuple[str, dict], bool], tuple[str, int]]optional - an argument that allows users to overwrite the way items are listedstart_line: intoptional - the line to start at in the selection. Will error if out-of-boundsstart_pos: intoptional - the amount of lines to pan down. Will error if out-of-bounds
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: stroptional - the default value before modificationvalidator: Callable[[str], bool]optional - 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: stroptional - 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.3.4.tar.gz.
File metadata
- Download URL: ui_forge-1.3.4.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
151e64b878ccbdfe93c946520ca56ef450350388aaa1648168f8c223f59a2e14
|
|
| MD5 |
fc6ba51b094ac84f181f59f494ca2ea2
|
|
| BLAKE2b-256 |
ecaf840ef9baf98d7d60a99ad9eada97f4b33d750ec1ccb7641b44fe54507176
|
File details
Details for the file ui_forge-1.3.4-py3-none-any.whl.
File metadata
- Download URL: ui_forge-1.3.4-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
483f80a5cc1088bb545bfd7bd30f3abb807d61da4d18a29068cd8a89a2dd37bc
|
|
| MD5 |
0ab8f4599134945aa987725e1c62ce6b
|
|
| BLAKE2b-256 |
19145f7f3f24c901c794f4b11876f11310577cde7872c634924aa0a0286261d2
|