Outstanding Tutorial on writing GTK+ 3 GUI Applications with Python

GUI programming has always been a black art to me. The idea of event-driven applications with an endless infinite loop listening for events boggles my mind a bit and runs counter to my traditional understand of what algorithms look like.  This is something that I struggle the most with Javascript (which has the benefit of having most of the details abstracted away by the browser), and something that I have never been able to quite grasp using traditional GUI tools like GTK, Qt, and even .NET.

The trend these days is to just use Electron. It seems like more and more apps (Slack, WordPress, Ghost, Postman, Visual Studio Code, etc.) are drinking the cross platform cool aid. I read this article which discusses some of the negative aspects of choosing Electron as a GUI framework. Drew makes some great points and the following paragraph inspired me to once again take a stab at actually learning a proper GUI framework.

Learn how to use GTK or Qt. Maybe Xwt is more up your alley. How about GNOME’s Vala thing? Learn another programming language. Learn Python or C/C++ or C#. Fun fact: it’ll make your JavaScript better, and once you have it in your toolbox you can make more educated decisions on the appropriate tool to use when you face your next problem.

Source: Electron considered harmful – Drew Devault’s Blog

PyGObject (aka PyGI) is the new way of developing GTK+ 3 GUI applications in python. On Ubuntu, installing the python3-gi package is enough to get started making your application “do something”. I found an excellent tutorial on using PyGI which does a great job explaining both basic and advanced concepts.

This tutorial gives an introduction to writing GTK+ 3 applications in Python.

Source: The Python GTK+ 3 Tutorial — Python GTK+ 3 Tutorial 3.4 documentation

In addition, this tutorial also has a section on how to use Glade, which is a GUI tool for building GUIs. For any substantial project hard coding the UI is going to get old pretty quickly.

The Python GObject Introspection API is massive. It solves a lot of common problems and also lets you work with a lot of existing GNOME applications. Looking forward to making something useful soon.

An Ode to Linux Desktop Users Everywhere

Here’s to the crazy ones, the misfits, the rebels. The package makers, the man page writers. The rounded windows in Qt mixed with the less rounded windows of GTK. The ones who literally see things differently because of missing proprietary fonts.

They’re not fond of rules, installation wizards, double clicking and have no respect for the status quo.

You can downvote them, disagree with them, glorify or vilify them. About the only thing you cannot do is ignore them. Because they ship your bug fixes.

They invent. They imagine. They heal. They explore. They create. They inspire. They push the human race forward.

Maybe they have to be crazy. How else can you stare at an empty screen and know that you have to blacklist your video card driver? Or sit in silence while tweaking alsamixer on the command line? Or write bash aliases to reload your network driver kernel module each time your laptop resumes from suspension? We make tools for these kinds of people.

While some may see them as the crazy ones, we see genius. Because people who are crazy enough to think that they can run Linux on the desktop, are the ones who change the world.