Monday, July 8, 2013

Automatically create a GUI for your argparse based command line tool


You are asked to create small tool in python to help someone out. Someone else comes along who wants to reuse the tool, but needs a minor variation on the theme. No problem, you think, I'll just add a command line option using python's argparse module.

Fast forward one month. The tool proves to be a success, but everyone wanted something slightly different, leading to 15 command line options. Now people start to complain that they lose oversight over the command line options. Other people see the potential in your tool but they are afraid of command lines altogether...

You realize you could please your users by giving them a UI to set up the command line options. But creating a UI is a lot of work... What now?

Argparseui to the rescue!

If you think you may get away with a zero-effort but ugly auto-generated UI, perhaps argparseui (python2.7 and python3, GPLv3) can be of use. Argparseui depends on PyQt.

As of yet it doesn't support all of argparse, nor does it officially support python3 (although basic use cases seem to work with python3), but it seems to scratch my itch.

Example code?

 Using argparseui is very similar to using argparse. Here's an example:


This is a screenshot made on Linux, IceWm. On windows, the dialog will look like a windows dialog, and on Mac OsX it should look like a Mac OsX dialog...


  1. finally it make sense to learn about argparse :)
    Is it still active project for you? There are some possible extensions - and this thing will fly on sysadmin and dataadmin screens

    1. Hello Andrei. Argparseui is still active in the sense that I still use it myself in some tools. I have made some extensions since posting this announcement. If you have ideas/suggestions, feel free to log some issues on github (or create a pull request with some changes).

      logging requests/issues:
      installing the library: