Adding a GUI to a Python script

We can quite easily add a GUI to a Python script by using the PyQt module ( ).

As an example, I use a command-line script described in a previous post (in Italian): La pendenza topografica lungo direzioni variabili ( This script calculates the directional slope of a DEM along orientations defined in an accompanying grid. These orientations typically vary in space and can represent for instance wind directions or glacial flows.

A more recent version of this script has also a GUI, obtained by changing just a few tens of code lines and without the need of Qt Designer ( In this last version, the GUI manages the definition of the input files and calculates the output slope grids according to two methods: a central differences method and Horn (1981) method. One can look at for additional details, download and a case study.

A valuable book for learning GUI scripting in Python is Rapid GUI Programming with Python and Qt, by Mark Summerfield ( ). As a development environment, Python(x,y) ( has all the required dependencies, so that one can start coding GUI without additional installations.