{"id":7807,"library":"trogon","title":"Trogon","description":"Trogon is a Python library that automatically generates a Textual User Interface (TUI) for your Click Command Line Interface (CLI) applications. It inspects the Click app's schema to build an interactive TUI, offering an intuitive way to interact with complex CLIs. It also has experimental support for Typer. The project is actively developed by Textualize, and the current version is 0.6.0. While there isn't a strict time-based release cadence, new versions are released to address bug fixes and introduce new features.","status":"active","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/Textualize/trogon","tags":["click","textual","tui","cli","command-line","terminal-ui","typer"],"install":[{"cmd":"pip install trogon","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for CLI application introspection and TUI generation.","package":"click","optional":false},{"reason":"Powers the Textual User Interface (TUI) rendering.","package":"textual","optional":false},{"reason":"Optional dependency for building TUIs for Typer CLIs.","package":"typer","optional":true}],"imports":[{"note":"The `tui` decorator is directly available from the top-level `trogon` package. Older examples or common misconceptions might lead to importing from a non-existent `cli` submodule.","wrong":"from trogon.cli import tui","symbol":"tui","correct":"from trogon import tui"},{"note":"Used for integrating Trogon with Typer applications, introduced in v0.6.0. This import is specific to Typer CLIs.","symbol":"init_tui","correct":"from trogon.typer import init_tui"}],"quickstart":{"code":"import click\nfrom trogon import tui\n\n@tui()\n@click.group()\ndef cli():\n    \"\"\"A simple CLI with Trogon.\"\"\"\n    pass\n\n@cli.command()\n@click.option(\"--name\", default=\"World\", help=\"The name to greet.\")\ndef hello(name):\n    \"\"\"Greets a name.\"\"\"\n    click.echo(f\"Hello {name}!\")\n\n@cli.command()\n@click.argument(\"num1\", type=int)\n@click.argument(\"num2\", type=int)\ndef add(num1, num2):\n    \"\"\"Adds two numbers.\"\"\"\n    click.echo(f\"The sum is: {num1 + num2}\")\n\nif __name__ == \"__main__\":\n    # To run the TUI: python your_cli_file.py tui\n    # To run the CLI: python your_cli_file.py hello --name Alice\n    cli()","lang":"python","description":"This quickstart demonstrates how to add a Trogon TUI to a basic Click CLI. By adding the `@tui()` decorator to your Click group or command, Trogon automatically generates a TUI accessible via a new `tui` subcommand. Users can then run `python your_cli_file.py tui` to launch the interactive interface."},"warnings":[{"fix":"Upgrade Trogon to version 0.6.0 or later to ensure compatibility with Textual 0.54+. Ensure your Textual dependency is also up-to-date.","message":"Older versions of Trogon (pre-0.6.0) may experience layout issues or incompatibilities with Textual versions 0.54 and newer.","severity":"breaking","affected_versions":"<0.6.0"},{"fix":"Avoid using interactive prompts directly within Trogon-wrapped Click commands. Instead, leverage Trogon's generated input fields for arguments and options, or provide all necessary arguments directly when launching the command from within the TUI.","message":"Using interactive prompts (e.g., `click.prompt()` or `rich.Prompt.ask()`) within a Click command wrapped by Trogon can lead to visual glitches and input issues, where the system command prompt interweaves with the TUI.","severity":"gotcha","affected_versions":"All versions"},{"fix":"As of now, this is an open bug. A potential workaround might involve explicitly converting the string representation of boolean options (e.g., 'True', 'False') to actual `bool` types within your Click command function, or waiting for an official fix in future Trogon releases.","message":"Trogon has known issues with handling `click.option` of `type=bool` and can pass boolean values as strings instead of native Python booleans to the underlying Click command.","severity":"gotcha","affected_versions":"All versions up to 0.6.0 (as of last check)"},{"fix":"Monitor Trogon's GitHub issues for updates and official fixes. Ensure your Click library is also up to date, as newer Click versions might handle deprecations differently.","message":"There is an open issue regarding `click.BaseCommand` deprecation warnings when using Trogon.","severity":"deprecated","affected_versions":"All versions (depending on Click version)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade Python to a newer 3.x version (e.g., 3.9+) or use a Linux/WSL environment. This issue is less prevalent in later Python versions or non-Windows OS.","cause":"Trogon's internal mechanism for detecting the run string, specifically `Py_GetArgcArgv` from `ctypes`, can fail on certain Windows environments, particularly with Python 3.8.10.","error":"TypeError: 'NoneType' object is not subscriptable (often traced to detect_run_string.py on Windows)"},{"fix":"Do not explicitly set `standalone_mode=False` when Trogon is wrapping your Click application. Allow Click to run in its default `standalone_mode` when `trogon` is the entry point.","cause":"Trogon expects Click applications to run in their default `standalone_mode=True`. Explicitly setting `standalone_mode=False` when invoking the Click command can interfere with Trogon's introspection and execution.","error":"Trogon with standalone_mode of click is not working (e.g., when calling cli(standalone_mode=False))"},{"fix":"The correct import path for the `tui` decorator is directly from the `trogon` package: `from trogon import tui`.","cause":"Attempting to import the `tui` decorator from an incorrect submodule path, possibly based on outdated examples or assumptions.","error":"ImportError: cannot import name 'tui' from 'trogon.cli'"}]}