Name | ui-forge JSON |
Version |
2.2.1
JSON |
| download |
home_page | None |
Summary | A WIP procedurally generated TUI made in NCurses using Python for CCSM |
upload_time | 2024-11-11 23:09:30 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | Unlicense |
keywords |
curses
ui
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ui_forge Package Documentation
## Submodules
### ui_forge.actions Module
#### `ui_forge.actions.edit(base_win: window, item: Tuple[str, EditItem]) → str`
Opens an editor interface for modifying the value of an `EditItem` and returns the validated input from the user.
#### `ui_forge.actions.run_function(item: RunFunctionItem)`
Executes the function associated with the specified `RunFunctionItem`. This item should not return a value.
#### `ui_forge.actions.select(base_win: window, options: OrderedDict[str, OptionItem], item_display: Callable[[Tuple[str, Item], bool], Tuple[str, int]], start_line: int = 0, start_scroll: int = 0) → Any`
Displays a selection menu using the provided options and returns the value of the selected `OptionItem`.
### ui_forge.items Module
#### `class ui_forge.items.Item(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False)`
Bases: `object`
Base class for menu items, providing basic attributes and functionality.
#### `class ui_forge.items.EditItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, value: str, validator: Callable[[str], bool] = lambda _: True, allowed_human_readable: str = '', display_value: bool = True)`
Bases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)
Represents an item that allows users to edit a value.
**Args:**
- `value (str)`: The current value, which will be overwritten.
- `validator (Callable[[str], bool])`: Function to validate the user input; defaults to always accepting the value.
- `header (str)`: A header above what the user is editing; defaults to an empty string.
- `display_value (bool)`: Determines if the value is shown in the main interface; defaults to True.
**Args:**
- `description (str)`: A brief description of the item; defaults to an empty string.
- `always_show_description (bool)`: Indicates if the description should always be visible; defaults to False.
- `exit_after_action (bool)`: Indicates if the menu should exit after this item is selected; defaults to False.
#### `class ui_forge.items.OptionItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, value: Any, displayed_value: str = '')`
Bases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)
Represents an option in a selection menu.
**Args:**
- `value (Any)`: The actual value of the option.
- `displayed_value (str)`: The string to display for the option; defaults to an empty string.
#### `class ui_forge.items.RunFunctionItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, function: Callable[..., None], args: Tuple = (), kwargs: Dict[str, Any] = {})`
Bases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)
Represents an item that executes a specified function when selected.
**Args:**
- `function (Callable[..., None])`: The function to run; it must not return a value.
- `args (Tuple[Any, ...])`: Arguments to pass to the function; defaults to an empty tuple.
- `kwargs (Dict[str, Any])`: Keyword arguments for the function; defaults to an empty dictionary.
#### `class ui_forge.items.SelectionItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, value: Any, options: OrderedDict[str, OptionItem], display_value: bool = True, start_line: int = 0, start_scroll: int = 0)`
Bases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)
Represents an item that allows the user to select from multiple options.
**Args:**
- `value (Any)`: The currently selected value.
- `options (OrderedDict[str, OptionItem])`: Available options for selection.
- `display_value (bool)`: Determines if the value is displayed in the main interface; defaults to True.
- `start_line (int)`: The initial line selected in the options; defaults to 0.
- `start_scroll (int)`: The initial scroll position; defaults to 0.
#### `class ui_forge.items.SubMenuItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, menu: OrderedDict[str, Item])`
Bases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)
Represents a submenu that contains additional items.
**Args:**
- `menu (OrderedDict[str, Item])`: A collection of items that make up the submenu.
### ui_forge.selector Module
#### `class ui_forge.selector.Actions(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)`
Bases: `Enum`
Enumerates actions for the selector.
- `Action = 3`
- `Pass = 0`
- `Scroll_Down = 1`
- `Scroll_Up = 2`
#### `ui_forge.selector.dict_select(base_win: window, dictionary: OrderedDict[str, T], item_display: Callable[[Tuple[str, Item], bool], Tuple[str, int]], start_line: int = 0, start_scroll: int = 0) → Tuple[Tuple[str, T], Tuple[int, int]]`
Displays a selection interface using a dictionary of items and returns the selected item and its position.
#### `ui_forge.selector.display_dict(pad: window, dictionary: OrderedDict[str, T], selected_line: int, item_display: Callable[[Tuple[str, T], bool], Tuple[str, int]])`
Renders a dictionary of items in the specified window, highlighting the selected line.
#### `ui_forge.selector.get_max_display_length(dictionary: dict, item_display: Callable[[Tuple[str, T], bool], Tuple[str, int]]) → int`
Calculates the maximum display length of items in a dictionary based on the provided display function.
#### `ui_forge.selector.process_command(command: int, Keymap: Keymap = Keymap(Up=[259], Down=[258], Action=[10])) → Actions`
Processes a user command and returns the corresponding action.
#### `ui_forge.selector.scroll_down(current_line: int, scroll: int, max_scroll: int, window_top: int, window_bottom: int, offset: int = 2) → Tuple[int, int]`
Handles scrolling down in the selection menu and returns updated line and scroll positions.
#### `ui_forge.selector.scroll_up(current_line: int, scroll: int, offset: int = 2) → Tuple[int, int]`
Handles scrolling up in the selection menu and returns updated line and scroll positions.
### ui_forge.ui Module
#### `ui_forge.ui.dict_ui(base_window: window, ui: OrderedDict[str, Item], item_display: Callable[[Tuple[str, Item], bool], Tuple[str, int]] = default_item_display, start_line: int = 0, start_scroll: int = 0)`
Creates a user interface in a Curses window for interacting with an ordered dictionary of items.
**Args:**
- `base_window (curses.window)`: The Curses window for rendering the UI.
- `ui (OrderedDict[str, items.Item])`: An ordered dictionary of item names and their corresponding `Item` instances.
- `item_display (Callable[[Tuple[str, items.Item], bool], Tuple[str, int]], optional)`: Function to customize item display; defaults to `default_item_display`.
- `start_line (int, optional)`: Default selected line; defaults to 0.
- `start_scroll (int, optional)`: Default scroll position; defaults to 0.
#### `ui_forge.ui.editor_ui(base_window: window, name: str, value: str = '', validator: Callable[[str], bool] = lambda _: True, allowed_human_readable: str = '') → str`
Displays an editor interface for user input and returns the modified value.
**Args:**
- `base_window (curses.window)`: The Curses window for rendering the editor.
- `name (str)`: The prompt or title for the editor.
- `value (str, optional)`: Default value to display; defaults to an empty string.
- `validator (Callable[[str], bool], optional)`: Function to validate the input; defaults to a function that always accepts the value.
- `header (str, optional)`: A header above what the user is editing; defaults to an empty string.
**Returns:**
- `str`: The user-modified value after validation.
#### `ui_forge.ui.selection_ui(base_window: window, options: OrderedDict[str, OptionItem], item_display: Callable[[Tuple[str, Item], bool], Tuple[str, int]] = default_item_display, start_line: int = 0, start_scroll: int = 0) → Any`
Displays a selection menu in a Curses window for choosing from an ordered dictionary of options.
**Args:**
- `base_window (curses.window)`: The Curses window for rendering the selection menu.
- `options (OrderedDict[str, items.OptionItem])`: An ordered dictionary of option names and corresponding `OptionItem` instances.
- `item_display (Callable[[Tuple[str, items.Item], bool], Tuple[str, int]], optional)`: Function to customize item display; defaults to `default_item_display`.
- `start_line (int, optional)`: Default selected line; defaults to 0.
- `start_scroll (int, optional)`: Default scroll position; defaults to 0.
**Returns:**
- `Any`: The value of the selected `OptionItem`.
Raw data
{
"_id": null,
"home_page": null,
"name": "ui-forge",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "curses, ui",
"author": null,
"author_email": "CJ <cjendantix@proton.me>",
"download_url": "https://files.pythonhosted.org/packages/d3/49/12477e0ac59bc6b5cd446bf6b20376abe3d35bf4baa35af5ea19e4c16b75/ui_forge-2.2.1.tar.gz",
"platform": null,
"description": "# ui_forge Package Documentation\n\n## Submodules\n\n### ui_forge.actions Module\n\n#### `ui_forge.actions.edit(base_win: window, item: Tuple[str, EditItem]) \u2192 str`\nOpens an editor interface for modifying the value of an `EditItem` and returns the validated input from the user.\n\n#### `ui_forge.actions.run_function(item: RunFunctionItem)`\nExecutes the function associated with the specified `RunFunctionItem`. This item should not return a value.\n\n#### `ui_forge.actions.select(base_win: window, options: OrderedDict[str, OptionItem], item_display: Callable[[Tuple[str, Item], bool], Tuple[str, int]], start_line: int = 0, start_scroll: int = 0) \u2192 Any`\nDisplays a selection menu using the provided options and returns the value of the selected `OptionItem`.\n\n### ui_forge.items Module\n\n#### `class ui_forge.items.Item(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False)`\nBases: `object`\n\nBase class for menu items, providing basic attributes and functionality.\n\n#### `class ui_forge.items.EditItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, value: str, validator: Callable[[str], bool] = lambda _: True, allowed_human_readable: str = '', display_value: bool = True)`\nBases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)\n\nRepresents an item that allows users to edit a value.\n\n**Args:**\n- `value (str)`: The current value, which will be overwritten.\n- `validator (Callable[[str], bool])`: Function to validate the user input; defaults to always accepting the value.\n- `header (str)`: A header above what the user is editing; defaults to an empty string.\n- `display_value (bool)`: Determines if the value is shown in the main interface; defaults to True.\n\n**Args:**\n- `description (str)`: A brief description of the item; defaults to an empty string.\n- `always_show_description (bool)`: Indicates if the description should always be visible; defaults to False.\n- `exit_after_action (bool)`: Indicates if the menu should exit after this item is selected; defaults to False.\n\n#### `class ui_forge.items.OptionItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, value: Any, displayed_value: str = '')`\nBases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)\n\nRepresents an option in a selection menu.\n\n**Args:**\n- `value (Any)`: The actual value of the option.\n- `displayed_value (str)`: The string to display for the option; defaults to an empty string.\n\n#### `class ui_forge.items.RunFunctionItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, function: Callable[..., None], args: Tuple = (), kwargs: Dict[str, Any] = {})`\nBases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)\n\nRepresents an item that executes a specified function when selected.\n\n**Args:**\n- `function (Callable[..., None])`: The function to run; it must not return a value.\n- `args (Tuple[Any, ...])`: Arguments to pass to the function; defaults to an empty tuple.\n- `kwargs (Dict[str, Any])`: Keyword arguments for the function; defaults to an empty dictionary.\n\n#### `class ui_forge.items.SelectionItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, value: Any, options: OrderedDict[str, OptionItem], display_value: bool = True, start_line: int = 0, start_scroll: int = 0)`\nBases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)\n\nRepresents an item that allows the user to select from multiple options.\n\n**Args:**\n- `value (Any)`: The currently selected value.\n- `options (OrderedDict[str, OptionItem])`: Available options for selection.\n- `display_value (bool)`: Determines if the value is displayed in the main interface; defaults to True.\n- `start_line (int)`: The initial line selected in the options; defaults to 0.\n- `start_scroll (int)`: The initial scroll position; defaults to 0.\n\n#### `class ui_forge.items.SubMenuItem(*, description: str = '', always_show_description: bool = False, exit_after_action: bool = False, menu: OrderedDict[str, Item])`\nBases: [`Item`](#class-ui_forgeitemsitem-description-str---always_show_description-bool--false-exit_after_action-bool--false)\n\nRepresents a submenu that contains additional items.\n\n**Args:**\n- `menu (OrderedDict[str, Item])`: A collection of items that make up the submenu.\n\n### ui_forge.selector Module\n\n#### `class ui_forge.selector.Actions(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)`\nBases: `Enum`\n\nEnumerates actions for the selector.\n\n- `Action = 3`\n- `Pass = 0`\n- `Scroll_Down = 1`\n- `Scroll_Up = 2`\n\n#### `ui_forge.selector.dict_select(base_win: window, dictionary: OrderedDict[str, T], item_display: Callable[[Tuple[str, Item], bool], Tuple[str, int]], start_line: int = 0, start_scroll: int = 0) \u2192 Tuple[Tuple[str, T], Tuple[int, int]]`\nDisplays a selection interface using a dictionary of items and returns the selected item and its position.\n\n#### `ui_forge.selector.display_dict(pad: window, dictionary: OrderedDict[str, T], selected_line: int, item_display: Callable[[Tuple[str, T], bool], Tuple[str, int]])`\nRenders a dictionary of items in the specified window, highlighting the selected line.\n\n#### `ui_forge.selector.get_max_display_length(dictionary: dict, item_display: Callable[[Tuple[str, T], bool], Tuple[str, int]]) \u2192 int`\nCalculates the maximum display length of items in a dictionary based on the provided display function.\n\n#### `ui_forge.selector.process_command(command: int, Keymap: Keymap = Keymap(Up=[259], Down=[258], Action=[10])) \u2192 Actions`\nProcesses a user command and returns the corresponding action.\n\n#### `ui_forge.selector.scroll_down(current_line: int, scroll: int, max_scroll: int, window_top: int, window_bottom: int, offset: int = 2) \u2192 Tuple[int, int]`\nHandles scrolling down in the selection menu and returns updated line and scroll positions.\n\n#### `ui_forge.selector.scroll_up(current_line: int, scroll: int, offset: int = 2) \u2192 Tuple[int, int]`\nHandles scrolling up in the selection menu and returns updated line and scroll positions.\n\n### ui_forge.ui Module\n\n#### `ui_forge.ui.dict_ui(base_window: window, ui: OrderedDict[str, Item], item_display: Callable[[Tuple[str, Item], bool], Tuple[str, int]] = default_item_display, start_line: int = 0, start_scroll: int = 0)`\nCreates a user interface in a Curses window for interacting with an ordered dictionary of items.\n\n**Args:**\n- `base_window (curses.window)`: The Curses window for rendering the UI.\n- `ui (OrderedDict[str, items.Item])`: An ordered dictionary of item names and their corresponding `Item` instances.\n- `item_display (Callable[[Tuple[str, items.Item], bool], Tuple[str, int]], optional)`: Function to customize item display; defaults to `default_item_display`.\n- `start_line (int, optional)`: Default selected line; defaults to 0.\n- `start_scroll (int, optional)`: Default scroll position; defaults to 0.\n\n#### `ui_forge.ui.editor_ui(base_window: window, name: str, value: str = '', validator: Callable[[str], bool] = lambda _: True, allowed_human_readable: str = '') \u2192 str`\nDisplays an editor interface for user input and returns the modified value.\n\n**Args:**\n- `base_window (curses.window)`: The Curses window for rendering the editor.\n- `name (str)`: The prompt or title for the editor.\n- `value (str, optional)`: Default value to display; defaults to an empty string.\n- `validator (Callable[[str], bool], optional)`: Function to validate the input; defaults to a function that always accepts the value.\n- `header (str, optional)`: A header above what the user is editing; defaults to an empty string.\n\n**Returns:**\n- `str`: The user-modified value after validation.\n\n#### `ui_forge.ui.selection_ui(base_window: window, options: OrderedDict[str, OptionItem], item_display: Callable[[Tuple[str, Item], bool], Tuple[str, int]] = default_item_display, start_line: int = 0, start_scroll: int = 0) \u2192 Any`\nDisplays a selection menu in a Curses window for choosing from an ordered dictionary of options.\n\n**Args:**\n- `base_window (curses.window)`: The Curses window for rendering the selection menu.\n- `options (OrderedDict[str, items.OptionItem])`: An ordered dictionary of option names and corresponding `OptionItem` instances.\n- `item_display (Callable[[Tuple[str, items.Item], bool], Tuple[str, int]], optional)`: Function to customize item display; defaults to `default_item_display`.\n- `start_line (int, optional)`: Default selected line; defaults to 0.\n- `start_scroll (int, optional)`: Default scroll position; defaults to 0.\n\n**Returns:**\n- `Any`: The value of the selected `OptionItem`.\n",
"bugtrack_url": null,
"license": "Unlicense",
"summary": "A WIP procedurally generated TUI made in NCurses using Python for CCSM",
"version": "2.2.1",
"project_urls": null,
"split_keywords": [
"curses",
" ui"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "089908c3562771ee40f4e102c4762ffdc7b257980424039363ec9328573f0b67",
"md5": "572552b0d6cf8da9e2a3afa52e4acef4",
"sha256": "09a7af456cbcfc9ce15bb7e81a25bf1b579e66624985659fde5904e25cdb0212"
},
"downloads": -1,
"filename": "ui_forge-2.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "572552b0d6cf8da9e2a3afa52e4acef4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 9543,
"upload_time": "2024-11-11T23:09:28",
"upload_time_iso_8601": "2024-11-11T23:09:28.031448Z",
"url": "https://files.pythonhosted.org/packages/08/99/08c3562771ee40f4e102c4762ffdc7b257980424039363ec9328573f0b67/ui_forge-2.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d34912477e0ac59bc6b5cd446bf6b20376abe3d35bf4baa35af5ea19e4c16b75",
"md5": "8bde22d776b28e197bc4e8107092c29c",
"sha256": "04346825a6538799b67b5b2b84732e20d31698f04ced6728f7005a685689cabf"
},
"downloads": -1,
"filename": "ui_forge-2.2.1.tar.gz",
"has_sig": false,
"md5_digest": "8bde22d776b28e197bc4e8107092c29c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 9397,
"upload_time": "2024-11-11T23:09:30",
"upload_time_iso_8601": "2024-11-11T23:09:30.470761Z",
"url": "https://files.pythonhosted.org/packages/d3/49/12477e0ac59bc6b5cd446bf6b20376abe3d35bf4baa35af5ea19e4c16b75/ui_forge-2.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-11 23:09:30",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ui-forge"
}