Pirnat.com

On second thought, let’s not go to Camelot; it is a silly place

Pirnat.com header image 2

Review: wxPython in Action

July 4th, 2006 by Mike
Gravatar

wxPython in
Action

Authors: Noel Rappin and Robin Dunn
Published: March 2006 by Manning
Publications Company

ISBN: 1-932394-62-1
620 pages

If, like me, you’ve been living under a rock (inasmuch as one can in the world of cross-platform GUI toolkits), you might not have heard much about wxPython. And if, like me, you were
excited by the idea of quickly developing modern, robust GUI-driven
applications that can run, without changes, on Windows, Mac OS X, and various
UNIX-like systems, but turned off by the downright spartan and unforgiving
online documentation, you can get happy again–with the publication of Noel
Rappin and wxPython co-creator Robin Dunn’s wxPython in Action, there is finally a cogent, coherent hybrid
of tutorial and reference for wxPython that will get you out from under all
that clunky Tkinter code and doing cool stuff.

Like other volumes in Manning’s In Action series, wxPython
presents a comfortable combination of introduction, overview, and example that
encourages exploration and experimentation. The text is clear and concise,
offering a no-nonsense explanation of the most relevant portions of the
wxPython libraries and the best practices for their use, delivered at a
measured pace that never manages to overwhelm, and uncannily launches into
explanations of your questions just as they arise. Numerous reference
tables provide a handy guide to the details (object properties, method
signatures, events, etc.) that you’ll be coming back to in your own future
development. The expanded table of contents, listing each of the “how do I…”
subsections of each chapter, is also a nice feature that will help make
this a valuable reference. Code examples are functional, clean, and on-topic,
just the right size to illustrate the concept at hand, and nearly always
accompanied by illustrations of the resulting behavior.
All the code is available online, and it’s worth your time to either download
it and give it a spin, or key it yourself and see how it behaves on your OS of
choice. An especially nice feature of the example code in the book is that
it’s well annotated, either with a brief note or a bulleted number that will
be referenced in an in-depth explanation immediately following the code
listing; this helps the reader quickly zero in on the essential elements of
the example, and it’s surprising that such a useful technique is not more
frequently encountered in programming books. A few errors seem to have snuck
through the editing process, though, so deeply involved readers will want the
errata nearby when
monkeying with example code. Manning’s “Author Online” forums are also a
great resource if you get stumped along the way.

The book is divided into three major sections, each six chapters long. The
first, “Introduction to wxPython,” is primarily a tutorial that walks the
reader through the foundations of coding in wxPython-land. Newcomers to GUI
programming might find certain portions a bit dense and mildly
daunting–specifically chapters 2 and 3–but patience here will be rewarded
with a good understanding of critically important concepts, such as wxPython’s
event handling model, that will be leveraged over and over again throughout
the rest of the book. Chapter 4 introduces PyCrust and other tools from Patrick
O’Brien’s Py library that you can use for interactive debugging or even reuse
within your own wxPython applications. Chapter 5 is a real gem, providing an
excellent discussion and practical walkthrough of the refactoring process, an
exploration of the benefits of the Model-View-Controller pattern and how
to do MVC in wxPython, and illustrates how to unit test your wxPython app;
these are non-glamourous topics that help aspiring developers grow into good
professionals, and this is a perfect place to see these topics. Chapter 6
presents the construction of a simple but fairly polished toy sketch
application, a satisfying achievement that nicely rounds out the introductory
section.

The second section, “Essential wxPython,” begins the more reference-oriented
material, covering (unsurprisingly) the essential widgets of the wxPython
toolkit: text labels, text entry, buttons, checkboxes, and the like in
Chapter 7; frames (what most of us think of when they think of “windows”)
in Chapter 8; dialogs in Chapter 9; various flavors of menus in Chapter 10;
the ins and outs of sizers in Chapter 11; and basic graphics manipulation
(putting images on the screen, customizing the cursor, etc.) in Chapter 12.
Each subsection builds logically on the one that came before it, and likewise
each chapter follows from its predecessor, introducing new widgets just as
you’re ready for them. The text here is significantly lighter than in the
first few chapters, so this reads fairly quickly.

The third section, “Advanced wxPython,” covers some more complicated widgets
and topics that probably won’t be day-to-day concerns but which are important
enough that, when you need to know about them, they’re covered in the book:
list controls (think Windows Explorer or Macintosh Finder) in Chapter 13; grid
controls (think spreadsheet applications) in Chapter 14; the tree control
(think file system trees, or registry editors) in Chapter 15; HTML widgets (a
great idea for a help facility in your applications) in Chapter 16; the
wxPython printing framework in Chapter 17. Finally, Chapter 18 rounds things
out with a grab-bag of other topics that didn’t merit their own chapters but
which are good to know about anyway: using the clipboard, managing drag and
drop operations, timers, and threading issues.

To be fair, there are a few imperfections here, but they mostly amount to
personal nit-picking. While it’s probably not essential, there’s no
discussion of sound or other multimedia functionality; and from a structural
standpoint, the book would have benefitted from a brief afterword to launch
the reader into further reading or development activity. Finally, and this
might be slightly unfair as I’d just finished reading one of O’Reilly’s
Head First books when I picked up wxPython in Action, this book
could probably use a little more personality; when the occasional editorial
comment sneaks through, it’s a welcome break from the readable but positively
arid expanses of text and examples.

That said, there’s obviously still a lot here to love. wxPython is clearly the way to
build cross-platform GUI apps in Python; even Guido van Rossum, Python’s
creator and benevolent dictator, advocates it, saying, “wxPython is the best
and most mature cross-platform GUI toolkit… the only reason wxPython isn’t
the standard Python GUI toolkit is that Tkinter was there first.”
wxPython in Action is clearly the authoritative resource
on the subject, a great introduction that will also serve as an excellent
reference for years to come. Recommended for wxPython n00bs and gurus alike.

Tags: books  geekery  python  wxpython4 CommentsPrint This Post

Leave A Comment

4 responses so far ↓

  • 1 siege Jul 4, 2006 at 11:04 pm Gravatar

    Do you know if the errata notes have been combined into the PDF version of the book?

  • 2 exilejedi Jul 4, 2006 at 11:06 pm Gravatar

    I don’t, but I’ll ask my contact at Manning and let you know.

  • 3 sharaf_maksumov Apr 18, 2007 at 9:36 am Gravatar

    Great stuff man!

  • 4 aleciak Jun 20, 2007 at 11:56 am Gravatar

    One thing they should try and do is take the next version to the next level. And that would be to make it in a series of short video tutorials. There is the technology these days to do it. And Dunne should. You see, it’s just sitting down and creating them. I think that would be so much easier for the user. And think about the money they could charge. (Er.. Coming from someone who has never produced anything in her life! lol)

    Allie PSP Game Champion 2006