GUI Programming with Python Using the Qt Toolkit
Update: It can be hard to actually buy the book, especially if you're European. If you have trouble ordering from your bookseller or the publisher, please mail me (firstname.lastname@example.org), and I'm sure I can help you to a copy.
My book is published! My book is published! After nine months of really intensive typing, GUI Programming with Python Using the Qt Toolkit is available. Published by Opendocs, you can buy a copy from the publishers, or from Amazon, or your local bookstore (they might have to order it, though: the isbn is 0-97003300-4-4).
You can also read it online, at linuxports.
I've ported and packaged the source code for all the examples in the book GUI Programming with Python using the Qt Toolkit has been ported to the latest version of PyQt and Qt.
PyQt is constantly in development, and that means that sometimes old code stops working as well as it did. Yigal Duppen has graciously hacked Kalam, the main example in the book to work with the latest versions of PyQt. You can download the new code here.
Tempus fugit irreparabile, and the breakneck pace of the development of both software and insight mean that what was once solid truth, is now merely obsolete drivel. And, of course, since errare humanum est and homo sum, humani nihil a me alienum puto, there are bits in the book that were drivel to begin with.
Chapter 14, p 266
def tearaDown(self): should be def tearDown(self):. Thanks to Helge Stenström for spotting this!
As Ka Yee Joanna Chan from the University of New South Wales pointed out, the example code for Chapter 15, file mdiapp.py, has somehow become corrupted. The line def queryFileName(self, document) misses; the code as supplied with later chapters is correct.
Constructor initialisation (P. 85)
While I was writing, Python got updated, and it's no longer necessary to write:
apply(QPushButton.__init__,(self,) + args)
You can now simply write:
Note the asterisk with args.
p. 249: self.connect(planaction, ... becomes self.connect(planAction, ....
p. 463: label = new QLabel(...: get rid of the new. That's what you get when you also work in java.
Layout of code
Somehow, it appeared impossible for Opendocs to print the code in a monospaced font. It's a rather small roman type now. Sorry for the inconvenience!
Unicode strings: page 132
Either Python has changed while I was not looking, or I was extremely sleepy when testing this script. Until we can write our source files in utf-8 (see PEP-0263), you can, if you must, enter utf-8 string literals directly, put your literal unicode characters in a plain Python string, and use unicode to convert the string to a Unicode object:
def ipa(): return unicode("ɱnɳɲƞɴʙrʀɾ", "utf-8")
A conversion error in the framework of chapter 16: the setBackgroundColor function has become setEraseColor. Thanks to Hans-Peter Jansen for pointing this out. Here's the diff.
Threading and PyQt: page 208
As of today (April 15th, 2002), QThread, aApp.lock(), QMutex and related classes still don't work. You can use Python's threading module threads, putting the results in a Queue, and retrieving the contents of the queue with a timer. See my addition to the article: Jacob Hallé's ActiveState cookbook recipe.
This works equally well with Stackless Python's microthreads, of course. See my article on the topic on InformIT.
With the latest versions of PyQt the Qt threading classes should work fine.
text and illustrations © 1999 Boudewijn Rempt