Hi there! Over the past several months I really enjoyed the perks of dynamic programming languages like Ruby and Python, to name the most outstanding ones. They are easy to use with a REPL, encourage you to cover your software with tests, what you always should do and you get stuff done pretty quickly.

But to quote a famous (now Disney) villian - "I find your lack of GUI (builders) disturbing". I always found it hard to develop a GUI or use available GUI frameworks both for python and ruby. So when I needed a GUI for a tool I had to develop I usually fell back to C++ and Qt, which is the most advanced GUI system in my opinion (especially with the QtBuilder). So I always wondered if there is possibility to use the strength and experience of Qts GUI concept and the andvantages of dynamic programming languages such as python. And in deed there is, called PyQt.

PyQt is a binding for Qt written in python. It is available for python 3.4 and 2.7, which are the most frequently used versions. So I tried it today and I'm so stunned, that I'd like to share it with you right now.

For starters: I'm using Windows at home, which makes the installation of PyQt very easy, since they provide a one click installer. So I cannot say anything about the effort of installation on other operating systems. Anyway as I mentioned, they have a one click installer, which copies all the files you'll need to your computer. With only 30mb of size I was a bit sceptical but in the end it was all fine.

Afterwards I googled for a tutorial in order to get started. I stumbled over that one, which covers the basics. So following this tutorial was fairly easy. I started with building the GUI with the QtBuilder (the strength) and set up the signals and slots, which are used later on (experience). After that I had to run a command line tool provided by PyQt. This was the first dangerous spot. Windows and command line tools - without setting the path manuallyin beforehand? But it worked like a charm. It transformed my *.ui file into python code, which I have to import in order to use my form. Then in my main python file I used the following code:

import sys

from PyQt4 import QtCore, QtGui
from form_ui import Ui_Form # this imports my GUI from form_ui.py

class MyForm(QtGui.QMainWindow):
	def __init__(self, parent=None):
		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_Form()

if __name__ == "__main__":
	app = QtGui.QApplication(sys.argv)
	myapp = MyForm()

After executing this small piece of code my form popped up, which surprised my a little bit, since this works too well. And also the predefined signals and slots worked as intended. And this whole procedure took me about 10 minutes, including reading the article mentioned above.

There you go. The strength and experience of a reliable GUI framework (I don't want to reduce Qt only to its GUI, but that's what I'm mainly using) combined with the perks (easy to develop, interactive, everything at runtime (!) and many more) of a dynamic programming language. And to tap it all off: It works on windows.

For everybody who didn't give it a shot by now, I highly recommend it to you. Happy coding.