GUI Programming with Python: QT Edition
GUI Programming with Python: QT Edition
Boudewijn Rempt
Copyright © 2001 by Commandprompt, Inc
Copyright (c) 2001 by Command Prompt,
Inc. This material may be distributed only subject to the
terms and conditions set forth in the Open Publication
License, v1.0 or later (the latest version is presently
available at http://www.opencontent.org/openpub/).‘Distribution of substantively modified
versions of this document is prohibited without the explicit
permission of the copyright holder.' to the license reference
or copy.‘Distribution of the work or derivative
of the work in any standard (paper) book form is prohibited
unless prior permission is obtained from the copyright
holder.' to the license reference or copy.
Although every reasonable effort has been made to
incorporate accurate and useful information into this book,
the copyright holders make no representation about the
suitability of this book or the information therein for any
purpose. It is provided "as is" without expressed
or implied warranty.
Dedication
This book is dedicated to Irina.
List of Tables 1-1. GUI Toolkits for Python 7-1. Matrix of
QObject.connect()
combinations. 10-1. Qt and Python high-level datastructures 10-2. Qt and Python network classes C-1. C++ access specifiers and sip C-2. Command line options C-3. Macros in Makefile Templates C-4. Flags in member function declaration C-1. Error flags in sipParseArgs() C-2. Format specifiers for
sipParseArgs()List of Figures 10-1. Qt Inheritance Hierarchy (only the most important classes) 10-2. Object Ownership Hierarchy 20-1. Playing with eval() 20-2. Playing with exec 20-3. Playing with
execfile()List of Examples 1-1. Bootstrapping a Python application 6-1. hello1.py — hello world 6-2. hello2.py — a better hello world 6-3. fragment from hello3.py 6-4. Fragment from hello5.py 6-5. Fragment from hello4.py 6-6. frmconnect.py 6-7. dlgconnect.py — the subclass of the generated form 7-1. A stupid button which is not reusable 7-2. A simple callback system 7-3. A central registry of connected widgets 7-4. Connecting a signal to a slot 7-5. Connection a dial to a label with signals and slots 7-6. Python signals and slots 7-7. Python signals and slots with arguments 7-8. datasource.py — connecting and disconnecting signals and
slots 7-9. An XML parser with signals and slots 8-1. qstring1.py — conversion from
QString to a Python string. 8-2. qstring2.py - second try of saving a
QString to a file 8-3. empty.py - feeding zero bytes to a QCString 8-4. null.py - empty and null QCStrings and Python
strings 8-5. emptyqstring.py - feeding zero bytes to a
QString 8-6. Loading an utf-8 encoded text 8-7. Building a string from single Unicode
characters 8-8. sitecustomize.py — saving a useful
function from wanton destruction 8-9. uniqstring3.py - messing with Unicode strings
using utf-8 as default encoding 8-10. uniqstring1.py - coercing Python strings into
and from QStrings 8-11. uniqstring2.py - coercing Python strings into and from
QStrings 9-1. refs.py - showing object references 9-2. circular.py - circululululular references 9-3. qtrefs1.py — about Qt reference counting 9-4. qtrefs2.py - keeping a Qt widget alive 9-5. qtrefs3.py - Qt parents and children 9-6. Eradicating a widget 9-7. children.py - getting the children from a single
parent 9-8. Iterating over children 9-9. sigslot.py - a simple signals/slots implementation
in Python, following the Observer pattern 9-10. Object introspection using Qt 9-11. Object introspection using Python 10-1. event1.py - handling mouse events in PyQt 10-2. action.py - Using a QAction to group data associated with
user commands 10-3. fragment from mdi.py - ten little scribbling windows 10-4. event2.py - using QWidget to create a custom,
double-buffered drawing widget. 10-5. snippet from event3.py - a peach puff drawing
board 10-6. fragment from action2.py - You cannot create a
QPixmap before a QApplication 10-7. buttons.py - Four pushbuttons saying
‘hello'. 10-8. label.py - a label associated with an
edit control 10-9. radio.py - a group of mutually exclusive
options 10-10. listbox.py - A listbox where data can be
associated with an entry 10-11. tree.py - building a tree 10-12. layout.py - two box layouts and adding and removing buttons
dynamically to a layout 10-13. geometry.py - setting the initial size of an
application 10-14. dialogs.py - opening message and default dialogs boxes 10-15. fragment from dialogs.py - opening a file dialog 10-16. fragment from dialogs.py - opening a font dialog 10-17. fragment from dialogs.py - opening a color dialog 10-18. from dv_qt.py - using Qt utility
classes 10-19. fragment from db_python.py - using Python utility classes 10-20. Using QMimeSourceFactory (application.py) 10-21. thread1.py — Python threads without
gui 10-22. Python threads and a PyQt gui window 11-1. dlgcomplex.py — a subclass of frmcomplex.py 11-2. Setting default values 12-1. A simple document-view framework 12-2. Scripting an application is easy 13-1. Defining a complex toggle action 15-1. A testcase for a document manager 15-2. The document manager class 15-3. The document class 15-4. The view class 15-5. The application class 21-1. typometer.py - A silly type-o-meter that keeps a
running count of how many characters are added to a certain
document and shows a chart of the typerate... 21-2. charmap.py - a Unicode character selection
widget 22-1. remote.py - remote control application 22-2. view.py - the main view of the remote control
application 22-3. button.py - the class that implements the pixmapped
buttons 22-4. A Qt 2 custom style - a minimalist
implementation of the classic Mac style in PyQt. 22-5. Testing styles 23-1. Handling drop events 23-2. Drag and drop 25-1. Installing the translator 26-1. README 26-2. setup.py - a sample setup script 26-3. MANIFEST.in C-1. Interface for
QRegExp::match