Main image of article 7 Top Python GUI Frameworks
As a Python developer, sooner or later you'll want to write an application with a graphical user interface. Fortunately, there are a lot of Python GUI options: The Python wiki on GUI programming lists over 30 cross-platform frameworks, as well as Pyjamas, a tool for cross-browser Web development based on a port of the Google Web Toolkit. (That's in addition to all the other tweaks you can make to optimize your Python code.) How to choose between all these options for Python GUI? I started by narrowing it down to those that included all three platforms (Windows, Mac, and Linux) and, where possible, Python 3. After that filtering, I found four toolkits (Gtk, Qt, Tk, and wxWidgets) and seven frameworks (Kivy, PyQt, gui2Py, libavg, wxPython, Pyforms, and PyGOBjects). Here's why I like them.

Kivy

One of the more interesting projects, the liberal MIT-licensed Kivy is based on OpenGL ES 2 and includes native multi-touch for each platform and Android/iOS. It's an event-driven framework based around a main loop, and is thus very suitable for game development. Your application adds callbacks from the main loop at a scheduled frequency, or by one-off trigger. The Kivy framework is very powerful for handling everything from widgets to animation, and includes its own language for describing user interface and interactions. If you want to create cross-platform graphical applications, or just need a very powerful cross-platform GUI, Kivy is highly recommended.

Pyforms

At just two years old (making it one of the more recent frameworks), Pyforms is a Python 2.7/3.x cross-environment framework for developing GUI applications. It is modular and encourages code reusability with minimal effort. Based on PyQt, OpenGL and other libraries, it provides a quite comprehensive set of 22 controls, all based on a ControlBase object; it also includes a video player, web browser and OpenGL. Read the Pyforms online docs to get a feel for it.

PyGObject (a.k.a. PyGi)

PyGObject is a module that lets you write Python applications for the GNOME project or a Python application using GTK+. It provides bindings to GObject, a C cross-platform library that offers common types and a baseclass to a large code base and has been used in many projects since 2002; for example, in the GIMP image manipulator, for which GTK+ was developed. GTK+ is a comprehensive free software cross-platform widget toolkit that offers GUI capability in many Linux and Windows/Mac OSX applications.

PyQt

Qt is a multi-licensed cross-platform framework written in C++. If your application is completely open source, you can use Qt for free under the community license; otherwise you’ll need a commercial license. Qt has been around for a long time and was owned by Nokia for a while; it's a very comprehensive library of tools and APIs, widely used in many industries, and covers many platforms including mobile. If a gadget such as a SatNav has a GUI, there's a good chance it'll be Qt based.

PyGUI

Compared to Kivy and PyQt, PyGUI is considerably simpler and just for Unix, Macintosh and Windows platforms. Developed by Dr. Greg Ewing at the University of Canterbury in New Zealand, the MVC framework focuses on fitting into the Python ecosystem as easily as possible. One of the platform’s aims is to interpose as little code as possible between the Python application and the platform's underlying GUI so the application's display always reflects the native GUI of the platform. If you're after a simple and quick way to learn GUI, start with this one.

libavg

This is another third-party library, written in C++ and scripted from Python, with properties of display elements as Python variables, a full-featured event handling system, timers (setTimeout, setInterval), support for logging and more. Like Kivy, libavg uses OpenGL and makes use of hardware acceleration. Libavg runs on Linux, Mac OS X and Windows, and is open source and licensed under the LGPL. It's been used extensively for artistic exhibitions and has a wide range of features such as a layout engine that can deal with thousands of objects (images, text, videos and camera output), fast video output, and a markup system for displaying text, as well as GPU shader effects such as blur, Chromakery and more. Plugins written in C++ have access to all libavg internals. If you ever see many people playing a multi-touch game on a large flat display, you might be looking at a good example of libavg in action.

wxPython

There have already been two books written about wxPython, making it worth a mention even if it isn’t quite ready for Python 3. WxPython is based on wxWidgets, a cross-platform GUI library written in C++. In addition to the standard dialogs, it includes a 2D path drawing API, dockable windows, support for many file formats and both text-editing and word-processing widgets. There's a great set of demos provided with wxPython, along with several sets of tutorials to help get you started. Given that wxWidgets has a 22-year development pedigree, this is one of the most popular frameworks. Make sure you read the wiki.

Conclusion

This is a great set of frameworks that should cover most needs (even if you're doing something totally esoteric like Python programming for finance!). All except PyQt are completely free. And just because we're nice, we're going to throw in two bonus platforms to think about here:

Traits/TraitsUI

A platform for building scalable and cross-platform GUIs, Traits/TraitsUI is capable of generating a user interface without additional coding (in theory). Offers solid documentation via GitHub.

PySimpleGUI

Who doesn’t love simplicity? PySimpleGUI, last updated Febuary 2019, is a cross-platform framework that wraps tkinter, Qt, wxPython and Remi. You can use it to build out GUI layouts with relatively little code, and there’s a lot of documentation here for those just getting started with Python.

Related Articles

Image: pyGUI