An application is better when it encourages and enables discoverability. Instead of being expected to memorize an entire user manual up front, users learn the application by using and exploring it. When I write Python applications, I like to use the Trogon library, which allows me to create a simple in-terminal GUI (called a “TUI”) to help users navigate the application visually.


To follow along with this tutorial, you must have:

  1. Linux distribution, preferably one that uses RPM (Like Fedora or Red Hat Enterprise Linux)
  2. Python 3.7 or greater
  3. Git
  4. A familiarity with virtual environments
  5. An Internet connection so you can download dependencies

Using Trogon

For this tutorial, I reuse the source code of my open source rpm_query application. The rpm_query application is a collection of simple commands that can query your system’s RPM database from a terminal.

Adding Trogon to your code is easy. First, add the new Trogon library as part of your code’s requirements.txt and setup.cfg files.

Then, add a new decorator to your code:

Yes, all it takes is one annotation (@tui) and an import!

Trogon in action

One reason I love Trogon so much is that your user doesn’t have to use a TUI if they don’t want to. The command-line is always available, as usual:

If you want to use the CLI options, you prepend the subcommand command before you provide any arguments. If you want to use the TUI, then you use the tui subcommand.

For help, you pass the --help option after the command subcommand:

The command works as expected:

The TUI mode helps users discover its features:


Using setuptools and Trogon

You can use setuptools with Trogon. Create a package called scripts inside the package called reporter.

Add the import and the annotation to the command function section:

A script called rpmq is created by setuptools, and it works exactly as expected.

What is next

  1. Download the source code for this tutorial and start experimenting.
  2. Trogon has great documentation and online support. Take advantage of it!


Jose Vicente Nunez

System Administrator/ DevOps.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *