Cross Platform GUI Development with Python and Qt
Rob Oakes | May 12, 2009 5:16 pm
One of computer programmers many fantasies (or at least one of my fantasies) is a cross-platform codebase that is easy to maintain. I want to write an application once and then be able to deploy in on any platform in existence. It should integrate into the destination environment in a native manner, but still be similar enough to the other platforms so that issues can be addressed in a way that doesn’t hinder overall progress.
Part of this dream can be fulfilled by using Python and standard library, it is also possible to do much of it by using IronPython and .Net (through the OpenSource Mono framework). However, in each case, you are forced to make a tradeoff. Python and the standard library are wonderful, if you are willing to accept a speed hit. IronPython and Mono also work well, as long as you avoid using any of the Windows specific libraries. Unfortunately, many of neatest .Net features (like Windows Presentation Foundation) are only available on Windows.
Okay, there is always GTK+ or wxWidgets (the same toolkits used for the Gnome desktop), but GTK+ is written in C and while much of the miscellaneous nastiness has been abstracted away, it is still one of the hardest toolkits to work with. Oh, and the documentation sucks. (When any documentation can be found at all.) Thus, we arrive at the final contender: Qt. Qt has had a long and controversial history involving license issues, passion, and miscellaneous geek pride. In fact, it’s due to Qt and some rather divisive decisions made by its developers that we even have alternative toolkits at all. But, despite that history, Trolltech’s recent decision to release the framework under the permissive LGPL license (rather than the noxious GPL) changes all that. In many ways, Qt might just become the cross-platform toolkit of choice
Of course, it’s a given that Qt is tremendously powerful with rich functionality. Applications that are written in Qt are fully cross-platform and behave the same way wherever they are deployed. It uses native widgets whenever possible and has a sophisticated theming system that allows it to follow platform conventions without significantly modifying the underlying code. More importantly, Qt is backed by a passionate developer community and a well funded corporation (Nokia). It is true, you get what you pay for. Qt is well designed and the documentation is simply fantastic. And unlike GTK+ or wxWidgets, the entire toolkit is written in proper object oriented C++.
I first started experimenting with the Qt framework about two months ago, after deciding to tackle a major add-on to one of my favorite writing programs, LyX. As I have said elsewhere, I am not the world’s most

gifted computer programmer (far from it actually), but Qt actually makes it pretty easy to get yourself up and running in a reasonable amount of time. If I were forced to do most of my GUI programming in Qt and C++, that would be an acceptable solution. However, that is completely unnecessary. You see, Qt has one of the most tightly integrated Python bindings available, through the user of PyQt from Riverbank software. Qt plus Python is, quite simply, programming perfection. So while I did some mild experimenting with the Qt frameworks in C++, I have spent much of the past few months doing the heavy work of learning the framework via the use of Python.
In the process, I have made a great many mistakes and a great many more discoveries. And since the final step in any discovery is to share your findings, I will be doing that through this series of articles. Of more interest to most, however, I will also be introducing the fruits of my labors: a somewhat functional prototype of my outliner add-on for LyX.
Show me more… »
Tags: PyQt
Categories: Computer, IronPython, Programming
2 Comments »










After finishing the 






















![Blackwater: The Rise of the World’s Most Powerful Mercenary Army [Revised and Updated]](http://ecx.images-amazon.com/images/I/41ZopVuqGsL._SL160_.jpg)
