Skip to main content

Python Process User Intent: A high-level abstract UI system (TUI, Web, Voice)

Project description

PPUI: Python Process User Intent 🎭

A high-level abstract UI system for Python scripts.

PPUI (pronounced "pui") is the Python implementation of the PUI (Process User Intent) philosophy.

The goal isn't just to "draw a menu"—it's to capture what the user wants to do next. Whether that intent is captured via a terminal hotkey, a web click, or a voice command, the script's logic remains the same.

PPUI: Because your scripts should care about what you want, not just how you say it.

Features

  • High-level Abstractions: Use concepts like Selection and Input without caring about the rendering engine.
  • TUI Implementation: Professional, hotkey-driven terminal menus.
  • Submenu Support: Nested selections with push (drill-down) or inline (expandable) behaviors.
  • Rich Integration: Full support for Rich-formatted output and panels.
  • Presentable Blocks: High-level CodeBlock, DataTable, and PanelSection primitives for showing code, tables, and sections.

Installation

pip install ppui

Usage

High-Level Menu Class

The Menu class provides a declarative way to build interactive loops with callback support.

from ppui import Menu

def run_setup():
    print("Running setup...")

def main():
    menu = Menu("Project Manager", style="bold green")
    menu.add_option("Setup Project", run_setup)
    menu.add_option("View Dashboard", "view_dash")
    
    # Submenu support
    advanced = Menu("Advanced Settings")
    advanced.add_option("DNS Config", lambda: print("Configuring DNS..."))
    menu.add_submenu("Advanced...", advanced, behavior="push")
    
    menu.add_back_item() 
    menu.add_quit_item()
    
    selection = menu.run()

Notes for AI Coding Agents

  • Think in intents, not widgets

    • Use PPUI to capture user intent (selections, confirmations, inputs), not to directly manipulate low-level UI widgets.
    • Application code should express what the user is choosing or providing, not how it is rendered.
  • Allowed imports in application code (e.g. services/*, media/*, utils/*):

    • From ppui (or helpers.core in PAS):
      • Menu, UIElement, Selection, Option, Presentable
      • CodeBlock, DataTable, PanelSection for high-level code/table/section rendering
      • prompt_yes_no, console, prompt_toolkit_menu, format_menu_choices, choice, copy_to_clipboard
    • From helpers.core:
      • run_command, load_pas_config, save_pas_config, and other non-UI helpers.
  • Forbidden in application code:

    • Direct imports from low-level UI libraries such as:
      • from rich.panel import Panel
      • from rich.syntax import Syntax
      • from rich.table import Table
    • Direct prompt_toolkit usage.
    • Direct questionary usage; use ppui’s choice(title, value) for shortcut-indexed menu items so questionary stays internal to ppui.
    • These are implementation details inside PPUI, not part of the public surface for tools.
  • Shortcut-indexed vs numeric-indexed menus:

    • format_menu_choices() prepends numeric indices (01., 02., …) to each item. Use it for menus where you want "01. Option A", "02. Option B" and selection by number or arrows.
    • When a menu is shortcut-indexed by design (e.g. q. Quit, p. Play/Pause, 0.9., b. Back), the label should show only that shortcut—e.g. "q. Stop tunnel and return to menu"—not "01. q. Stop tunnel...". In that case do not use format_menu_choices(). Build the list with choice("q. ...", "quit") (from ppui) and pass it to prompt_toolkit_menu(choices). Hotkeys are derived from the prefix before the first dot. questionary is internal to ppui; use choice(), do not import questionary.
  • Menu pattern to use (example):

from ppui import Menu, prompt_yes_no, console

def manage_project(path):
    while True:
        console.print(f"Managing: {path}")
        menu = Menu("Project Actions", style="bold cyan")
        menu.add_option("Deploy to Staging", deploy_staging)
        menu.add_option("Deploy to Prod", deploy_prod)
        menu.add_back_item()
        menu.add_quit_item()
        selection = menu.run(loop=False)
        if selection in ["back", "quit"]:
            break
  • Extending PPUI
    • If you need richer concepts (forms, layouts, dashboards, etc.), add new abstractions to PPUI (e.g. Form, Layout) and implement them here.
    • Do not introduce new rich/prompt_toolkit imports in application code; route them through PPUI so the same intent can later be rendered as TUI, web, or voice.

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

ppui-2026.2.23.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

ppui-2026.2.23-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file ppui-2026.2.23.tar.gz.

File metadata

  • Download URL: ppui-2026.2.23.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for ppui-2026.2.23.tar.gz
Algorithm Hash digest
SHA256 2309299c2cfc6189e4ec5a8d2160382f0da4b443b734f2eb27c29b9e9844c90e
MD5 2a7093e1357e6f26ff8bef0d4d9677e0
BLAKE2b-256 8832c98e02bc2dbf0b627e48e8cca07c33ff9e2452c98ea27dad21f5cfd0aadf

See more details on using hashes here.

File details

Details for the file ppui-2026.2.23-py3-none-any.whl.

File metadata

  • Download URL: ppui-2026.2.23-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for ppui-2026.2.23-py3-none-any.whl
Algorithm Hash digest
SHA256 0c951d41db2ca2195f2d95991d1f26573ebce3d0bc35132b6c529a4208654a04
MD5 ac42fb7f6b1a770e7c49d069995bca74
BLAKE2b-256 d655c96f20f7384cf3b75244e64a1affa3383db46702546d1da8868a9eeb7eb3

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