Preface
The main topic of this book is application
development using PyQt, a library extension to the Python
programming language — a library that is meant to form the
basis for GUI programming. PyQt is free software, but there is
also a commercial IDE available, BlackAdder, that is specially
written to assist working with PyQt. I will show you the ins and
outs of PyQt by developing a complete and complex application.
Like most thirty–somethings who
started programming in their teens, I've worked with a lot of
different technologies. I started with Sinclair Basic, going on
to Turbo Pascal and SNOBOL — I have developed for Windows
in pure C, with Borland Pascal and with Visual Basic. I've done
my stretch with Oracle Forms, and served as a Java developer. On
Linux, I've wet my feet with Free Pascal, with C++, using XForms
and Qt. And just when I was getting fond of Qt and C++, I found
out about Python — a few years ago now. I found
programming with PyQt to be a lot more fun than anything else,
and productive fun, too.
For sheer productivity, nothing beats
Python and PyQt. And while there's always something new to learn
or explore in Python, if you're in the mood, it's easy and
pleasant to write useful applications from the first day. No
other programming language or library has ever given me
that.
So, when Cameron Laird, during a
discussion on the comp.lang.python newsgroup suggested that I'd
write a book on this particular way of developing GUI
applications with Python, I started to think — and more
than think. I started to contact publishers, until one day Shawn
Gordon of TheKompany brought me into contact with Joshua Drake
of Opendocs. I started writing text and code almost
immediately.
Joshua's patience has been monumental
— I should have written this book between February and
May, but it took me until November. All I can say for myself is
that a lot of effort has gone into the book. I discuss most of
the concepts and classes of the Qt library, which might be
useful not only to Python developers, but also to C++
developers, and I have written a lot of
example scripts.
Where Bruce Eckel (of Thinking
in Java fame) favors small example programs
because they clearly illustrate the matter in hand, John Grayson
in Python and Tkinter argues that larger
real-life applications are more useful because they don't hide
the complexity that is a part of any programming effort.
Both are right, of course, so I decided to
give you both small examples and one really large one. Part I
and II of this book concern themselves with concepts: here the
examples are small, often amounting to less than one page of
code. Part III takes you through the development of a complete,
complex application. In this case an editor, but one with a lot
of extra features. I think it's a very good way of learning what
developing complex applications entails - I spare you none of
the nasty details that software development entails.
I have tried to keep to a very clear style
of coding, with few or none of the clever hacks that are
possible in Python — like adding the methods of one class
to another, or creating lists of function objects. The purpose
is to tell you about writing real applications using Python and
Qt. Clever hacking has its place, but is best savored on its
own.
The emphasis of the book is also firmly on
application development, not on creating graphics per se —
although several techniques are mentioned here and there that
have to do with creating charts and graphs.
Who is using PyQt
The combination of Python and Qt is
extremely powerful, and is used in a wide variety of
applications. People are scripting OpenGL applications with
it, creating complex 3D models, animation applications,
writing database applications, games, utilities and hardware
monitoring applications. It is used in open source projects,
but also by large companies, like Disney Television and Media.
If you're not working on embedded software, hardware drivers
or a new operating system, chances are that PyQt is the right
choice for you, too.