Skip to main content

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 required - the functionality of the item, valid values will be covered later. The program will most likely panic if this is ever not specified
  • description: str - a description of the option
  • always_show_description: bool - whether or not to always show the description of the item, if set to False, 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 the none functionality to implement an exit button.

dict_ui

Arguments:

  • base_window: curses.window - a curses window
  • dictionary: 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 listed

functionalities

  • none Does nothing. Will not inhibit functionality of global args.

  • run_function Runs a function with arbitrary arguments

    Sub Args:

    • function: Callable[[Unknown], None] - a reference to the function to run
    • args: list optional - a list of positional arguments to pass to the function
    • kwargs: dict[str, Unknown] optional - a dictionary of keyword arguments to pass to the function
  • edit Opens the editor widget

    Sub Args:

    • value: str - the value assigned before editing - this gets overwritten after a successful edit
    • validator: 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: str optional - 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.
  • select Opens the selection widget

    sub args:

    • value: str - the value assigned before editing - this gets overwritten when the user selects a new value
    • options: dict[str, dict] - a dictionary containing dictionaries in item format with the option functionality
  • option An option in a selection menu. Only intended to be used within the selection widget. The key is the value that will be selected.

  • sub menu A new instance of dict_ui with the input menu dictionary

    Sub Args:

    • menu: dict - a menu dictionary

selection_ui

Arguments:

  • base_window: curses.window - a curses window
  • options: dict[str, dict] - a dictionary containing dictionaries in item format with the option functionality
  • item_display: Callable[[tuple[str, dict], bool], tuple[str, int]] optional - an argument that allows users to overwrite the way items are listed

editor_ui

  • base_window: curses.window - a curses window
  • name: str - the "name" of the value being assigned, ususally analagous to the name of the variable being assigned to. This gets displayed to the user
  • value: str optional - the default value before modification
  • validator: 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: str optional - 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ui_forge-1.2.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ui_forge-1.2.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file ui_forge-1.2.2.tar.gz.

File metadata

  • Download URL: ui_forge-1.2.2.tar.gz
  • Upload date:
  • Size: 5.6 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

Hashes for ui_forge-1.2.2.tar.gz
Algorithm Hash digest
SHA256 8176ef54c0effd33a53783defea2eb4729ef14e9d0c2136b00acdede8c671912
MD5 86ddd1ff4dd2867022d4ee3ebc975cb8
BLAKE2b-256 c0f4f6006932cfec9295b09d1e9f5fb71391bd8c0ebe8b9df3d773c853fdcf3e

See more details on using hashes here.

File details

Details for the file ui_forge-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: ui_forge-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 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

Hashes for ui_forge-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 04787bb15f1a76ab76634643608d659f1bd5276f5d37e06141cfb70005e06b7d
MD5 ee06687d5a2f7b572a6a07a60b6ab4f6
BLAKE2b-256 b3b88f5b48286090eeaa2706b73d5e391f5f5e97371e21213d3f7086de735227

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page