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.
dict_ui
Arguments:
base_window: curses.windowa curses windowdictionary: dicta 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
dictionary format:
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
global args
These arguments will be on every item listed here.
functionality: strrequired - the functionality of the item, valid values will be covered laterdescription: 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.
functionalities
-
quitexits this instance of a menu. if selected in a sub menu it will return the user to the previous menu -
run_functionruns a functionsub args:
function: Callable[[Unknown], None]- a reference to the function to runargs: list | tuple- a list or tuple of positional arguments to pass to the functionkwargs: dict- a dictionary of keyword arguments to pass to the function
-
editopens the editor widget for an assigned valuesub args:
value: str- the value assigned before editing - this gets overwritten after a successful editvalidator: 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.
-
selectopens the selection widgetsub args:
value: strthe value assigned before editing - this gets overwritten when the user selects a new valueoptions: dict: a dictionary containing dictionaries with theoptionfunctionality
-
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: dicta menu dictionary
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.