-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
106 lines (89 loc) · 5.42 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Rapid GUI Programming with Python and Qt:
The Definitive Guide to PyQt Programming
by Mark Summerfield
ISBN: 0132354187
IMPORTANT NOTES
The examples included in this archive are _not_ the ones shown in
the book. The book's examples use Python 2.5/PyQt 4.3 and are
available separately from the same web page,
www.qtrac.eu/pyqtbook.html. That web page also has a set of the
examples for Python 2.6/PyQt 4.4.
The examples in this archive use Python 3.1/PyQt 4.7.3 and PyQt4's
API 2 (which is the default for Python 3.1).
Note that PyQt 4.5.0 is insufficient for the examples that use
Qt Designer .ui files.
Some of the examples include small improvements. The main changes
are to uses of QDataStream, QSettings, and QTextStream, the
replacement of QString methods with str methods, and adapting to the
automatic conversion to and from QVariant.
These versions of the examples have only been tried on Linux and not
tested much, so if you find bugs please let me know!
These examples are straight conversions of the book's original
examples---so they do not take any advantage of the new more
Pythonic APIs offered by PyQt 4.5 and later, nor of the new features
offered by Qt 4.4 and later; all that will have to wait for a future
edition.
All the example programs and modules are copyright (c) Qtrac Ltd.
2008-10. They are free software: you can redistribute them and/or modify
them under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
version 3 of the License, or (at your option) any later version. They
are provided for educational purposes and are distributed in the hope
that they will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public Licenses (in files gpl-2.0.txt and
gpl-3.0.txt) for more details.
Two helper programs are provided: mkpyqt.py (a console application), and
makepyqt.pyw (a GUI application). These programs both do the same thing:
They run pyuic4, pyrcc4, pylupdate4, and lrelease with the correct
command line arguments. In some cases you may need to set the path to
pyuic4 (pyuic4.bat on Windows), and possibly to the other programs as
well. For mkpyqt.py this means editing the file itself (the paths are in
variables near the top); for makepyqt.pyw, click "More->Options" and
set the paths there. The use of these programs is described in Chapter 7.
All the book's examples are designed to be educational, and many are
also designed to be useful. I hope that you find them helpful, and are
perhaps able to use some of them as starting points for your own
projects.
Qt is available with multiple licenses including the GPL and LGPL so in
many cases a commercial license is not necessary. To download Qt and for
the license terms visit http://www.qtsoftware.com. PyQt is dual
licensed, GPL and commercial. To download PyQt and for the license terms
visit http://www.riverbankcomputing.co.uk. Python itself can be obtained
from http://www.python.org and can be used for both commercial and
non-commercial purposes free of charge. See Appendix A for information
on obtaining and installing the necessary software.
Most of the icons are from KDE (The `K' Desktop Environment), and come
under KDE's LGPL license. (Visit http:///www.kde.org for more information.)
STOP PRESS
Chapter 3 describes an "OrderedDict". Unfortunately this name is
incorrect, it should have been called "SortedDict". (In Python mapping
terminology "ordered" means "order of insertion" and "sorted" means
"order of key"---I had used the C++ terminology.) I have kept the
wrongly named ordereddict.py module in the archive---after all, it works
fine---but also provided a correctly named SortedDict.py module that has
the same behavior, and that ought to be used instead. (The examples for
my book "Programming in Python 3" have an alternative SortedDict---and
SortedList---implementation.) Note that Python 3.1 comes with
collections.OrderedDict, an insertion ordered dictionary.
Chapter 4. I've now added a new example, currency2.pyw that has one
extra line (to include Canadian dollars) and one line different (to sort
currency names case-insensitively) compared to currency.pyw. I've also
done a small theoretical improvement to the code.
Chapter 9 shows an SDI text editor (sditexteditor.pyw) that has a Window
menu in every main window with the list of all the application's
windows. This application's Window menu works on the basis of window
titles. But window titles may not be unique. For this reason I have now
added a new version (sditexteditor2.pyw) that has more sophisticated
updateWindowMenu() and raiseWindow() methods that use each window's
unique id() rather than their possibly non-unique window title.
Chapter 12. The exercise solution pagedesigner_ans.pyw has an improved
setAlignment() implementation thanks to John Posner.
Chapter 13 shows a PythonHighlighter (color syntax highlighting) class
in the pythoneditor.pyw and pythoneditor_ans.pyw applications. I have
fixed bugs in the syntax highlighter used in both of these and now added
pythoneditor2.pyw which is a copy of pythoneditor_ans.pyw but with the
PythonHighlighter replaced with one that uses improved highlighting
logic since this works better in more corner cases (but is slower). I've
also added printing2.pyw which has a bugfix and some tiny improvements
for both HTML and QPainter printing.