EuroPython 2016

Metaclasses for fun and profit: Making a declarative GUI implementation

Speaker(s) Anders Hammarquist

When overhauling the user interface of Autolabel’s labeling printers, we wanted a clean way to describe the layout of the settings widgets. The structure we came up with was a declarative class layout that leverages Python’s metaclass concept to build the underlying GTK widget structure.

I will present the implementation to hopefully inspire you to apply metaclass techniques to problems that standard Python syntax can’t quite solve. If that fails, you will at least have a way to declaratively construct GTK GUIs.

A short, non-exaustive, summary of concepts I will mention includes metaclasses (obviously), class hierarchies, method resolution order, super(), and anecdotes of dealing with GTK.

You may find some similarities with my talk on Python as a domain specific language at Europython 2006

Slides are available at

Example code on Bitbucket

in on Wednesday 20 July at 12:00 See schedule

Do you have some questions on this talk?

New comment