Friday, 10 June 2016

Python UI + UX = Sex

Now that I have your attention, take a look at these excellent examples of my interface designs for Python scripts.

Commandline

Most small utility scripts coded in Python will run on the commandline in a Terminal or Console window. While this usually makes for a fast workflow, the experience can seem dry and lacking in visual cues that we are used to in Graphical User Interfaces.

Even here, good design is possible, harking back to the slowly refreshing and blinking screens of a lost golden age of mainframes and terminals.

My Quicknr web publishing tool is a commandline application, but the user experience is quite similar to working with a graphical window. While the mouse cannot be used, options are arranged into lists, to be selected with numbers or letters entered at the prompt. This is faster than clicking the mouse, there is a definite sense of "bam! bam! done!" when working this way.

Curses Module

The next step up is the "pseudo-GUI" design made possible by the curses module in Python. The script still runs in the Terminal, but the entire window is taken over, and a "graphical" interface created out of the textual character grid that the Terminal window defines.

In this example of a tax return application, you can see how additional visual cues can be used for a more intuitive user experience, and more real-time feedback can be provided to the user. Support for the mouse can also be programmed. However, because of the cumbersome nature of clicking in the character grid of this interface, mouse support is usually implemented only if absolutely necessary.

Tkinter

A real GUI can be constructed natively in Python, using the Tkinter module. This module has had a patchy history, falling out of favour for some time because of its non-standard appearance across different platforms. In more recent Python versions, the problem has been addressed sufficiently well that perfectly acceptable interfaces can be created, looking good on Windows, Mac and Linux. Quite a feat!

Comment Block Maker, my insanely useful utility for programmers, uses Tkinter for its interface. It is a simple design, but coded in a way that it can serve as a template for more complex use cases.

GTK+

Beyond Tkinter, a number of other GUI modules exist, the most popular being Qt, wxWidgets, and GTK+. They are quite similar to each other in the functionality that they offer. Applications exist that enable drag-and-drop construction of the GUI, making these options more appealing than Tkinter.

For my proprietary photo editing Python application, I used GTK+, and Glade as the GUI constructor. The idea of the app was to speed up the photo editing process in a "tab! tab! done!" workflow reminiscent of the commandline.

And there you have it: Python scripts can be used in any interface to your liking. If you need such a thing, get in touch!