GUI Programming with Python: Using the Qt Toolkit

Rempt, Boudewijn
OpenDocs, LLC 2001
ISBN 0-9700330-4-4
528pp
Date finished: 2003-04-28

I might be writing a GUI using PyQt in the near future, so I finally dug out my copy of this book and read it. Some of the material in the book is helpful, but many pages are expended on topics that are only tangentially related to GUI programming with PyQt. Ultimately the book is too unfocused, and I can't recommend purchasing it to learn PyQt, though looking at a few online chapters would be very helpful.

Part I contains five chapters that introduce Python and Qt, the Blackadder IDE, a brief Python language tutorial, and debugging techniques. Part II is the best part of the book, six chapters explaining the organization of the Qt library, how it's mapped to Python, and the intersection of Qt and Python strings. In particular, chapter 7 is excellent; it motivates Qt's signal/slot mechanism by building a simple Python implementation, and then showing how to use the Qt implementation. The book also contains a good section on how to read the Qt documentation, but it's relegated to Appendix A instead of being included in Part II where it belongs.

Part III is a mixed bag. Chapter 12 on application frameworks and chapter 13 on actions are good. Chapter 14 is on PyUnit, and its presence in this section is also a puzzle; why isn't it in Part I? Chapters 21 ("Drawing on Painters and Canvases"), 23 ("Drag and drop"), 24 ("Printing"), and 25 ("Internationalizing an Application") are also decent. The real problems come with other chapters; chapter 15 expends 30 pages on building a multidocument framework, even though we haven't seen how to work with widgets. In fact, this leads up to the book's biggest omission: most of the widgets aren't really covered anywhere! Chapter 10 is a 60-page tour of the Qt widgets that's pretty good, but no other chapter shows the details of working with them. The canvas is covered in chapter 21, dialogs in chapter 19, and there's some coverage of the text-editing widgets scattered around, but that's about it. Instead, we have chapters on using Python as a macro language, on writing and reading configuration files, on writing new themes -- all tasks that seem of second-order importance in comparison to dealing with the basic Qt widgets. I suppose the details may not have been thought necessary, because if you use Qt Designer you won't need to wrestle layouts and make connections yourself, but given the book's thickness, that means much of its content is off-topic.

Appendix B gives an example of using NumPy and a plotting widget from Qwt; it would make a good PyZine article introducing NumPy and Qwt, but it doesn't teach enough to use either library. Appendix C gives a very short introduction to using sip that isn't bad, but then includes 45 pages of man-style documentation for sip; users who just want to program with PyQt and not wrap new C++ libraries won't care, so this is a waste of space.

Here are my suggestions for reading it. Treat chapter 14 as being in part I; read it as chapter 6. Experienced Python programmers can just skip part I completely. Read all of part II, chapters 6 through 11 and appendix A; these are the heart of the book and contain the most information. Skip chapters 15, 18, 20, 22, 26, and appendix C. (Chapter 16 doesn't contain anything very critical, but it's short, so you might as well read it.)

The typography is awful, to put it bluntly. The most annoying problem is that the captions for images and screenshots are left-justified and in the same font/style as the text so captions look confusingly like one-line paragraphs. There are also many typos in the text, and some typos in the code. Code is set in a serifed variable-width font, which looks rather strange and means that multi-line expressions don't line up properly.

Tagged: interfaces, python

Permalink: http://books.amk.ca/2003/04/Python_Qt.html

%T GUI Programming with Python
%S Using the Qt Toolkit
%A Rempt, Boudewijn
%G ISBN 0-9700330-4-4
%D 2001
%@ 2003-04-28
%P 528pp
%I OpenDocs, LLC
%K interfaces, python

http://books.amk.ca

Contact me