Author Archives: britefury

Developing GTK 3 apps with Python on Windows

This blogpost is by Geoffrey French, who has joined us for the Docs Hackfest which is happening this week at the University of East Anglia, Norwich, UK.

Kat invited me to write this guest post on her blog, describing my experiences of the Norwich GNOME Docs Hackfest held at the University of East Anglia School of Computing Sciences over the last few days. I joined the hackfest as I recently started using Gnome 3 after installing Fedora 20. My personal website is at www.britefury.com. I am the author of two interactive programming environments for Python; The Larch Environment and The Ubiquitous Larch.

My initial focus was on helping developers get started with developing Gtk+ v3.x apps in Python for the Windows platform. I feel that Windows is an important platform due to the large user base; being able to develop software for them can only be a good thing.

My prior experience with developing Gtk+ apps in Python was gained while developing gSculpt, a 3D modelling program. At the time (2008) I targeted Gtk+ v2.x using the PyGtk Python bindings. Since Gtk+ v3.x however, PyGtk has been replaced with GObject introspection based bindings for external langauges.

Luckily getting started Gtk 3.x development on Python for Windows is very easy; thanks to the hard work of Simon Feltman et al there is a nice installer package that does all the work for you! You can also use either Python 2 or Python3 as a bonus.

The first (if obvious) step is to ensure that you have Python installed; either versions 2.7 or 3.3 are fine. Next, you need to install PyGObject. You can download the Win32 installer here. You get a large 130MB installer which comes bundled with PyGObject Gtk, glib and many other Gnome libraries; so no need to hunt down dependencies. When you run the installer, you will be asked to choose a Python interpreter to install for (2.x or 3.x if you have multiple interpreters installed). Next, you can choose the packages that you want; ensure that you select Gtk at least.

After that, you are good to go!

If you want to learn Gtk using Python, the Python GTK+ 3 tutorial would be a good place to start.

Writing about it

After finding out that getting going was so easy – and noticing that this fact was not immediately obvious – I decided that it would be good start to write about it, so that people can find this out.

Since I was going to be working on Windows, it seemed to make sense to try to write Mallard documents on Windows too. Unfortunately, getting Yelp installed was not nearly so easy. I regret to say, that after installing MinGW, some circular dependencies involving pkg-config and glib caused me to give up.

The Hackfest

I found out about the hackfest shortly before it was due to start. I decided to join and was greeted by welcoming and friendly faces who helped me get started quickly. I am happy to have met everyone and I hope to collaborate with them again in the future!