Sept 2004 TriZPUG meeting notes
wxPython and Boa Constructor
Tom Bryan, presenter (notes by Jim Allman)
wxPython is a cross-platform GUI widget library ... on top of wxWidgets (formerly wxWindows)
Includes Python modules and extension classes
Architecture (in several layers)
Here are all the layers, from "top to bottom":
- wxPython library
proxy classes
wxPython Extension Modules
wxWidgets Toolkit
Platform GUI
operating system
Alternative widget kits
PMW (Python MegaWidgets) builds on Tkinter, with more advanced widgets - might be worth another look
Qt is veeery nice, but commercial licenses are a killer (thousands/seat?) TrollTech (the Qt vendor) is expanding into IDEs (and GUI builders) and a more comprehensive app framework (XML rendering, etc) BlackAdder (from The Kompany) is a visual builder tool for Qt widgets The Kompany also has at least one full-time employee working on the Python bindings, so this is looking good.
GTK is a GNU project(?) to build a standard widget set - core set of C libraries, with optional C++ wrappers - pyGTK(?) is the Python wrapper; check for Mac version!
wxGlade is an alternate layout designer..?
wxPython and Boa Constructor docs
Things are good and bad here. Lots of docs, but sometimes details "on the ground" are scarce. Some of the classes are poorly documented (minimal docstrings and comments), and the docs are often carried wholesale from wxWidgets. This can be dicey (examples that don't map to Python), but OK for topical overviews and concepts.
Interesting tidbits
Funky namespaces in wxPython wx wx.gizmos (is this unique to wxPython?) Note that there are class naming conventions for wxPython classes, that are inherited from the C implementation beneath. Basically, everything is named wx.wxSomthing. Not strictly needed, but kinda handy if you use from wx import * since everything will have a pretty distinctive name.
Helpful sites wiki.wxpython.org (see Getting Started, etc) www.wxpython.org Check out the OSCON2004 presentations from Robin Dunn on this website (Presentations link on the homepage; these are huge and comprehensive.)
The docs included with wxPython are in Windows (CFM) format; if you're on another platform, use viewdocs.py to view these
Events and methods
A wxPython program is fundamentally event-driven (by usre actions, or system events). All code is attached to a main event loop, which dispatches events and triggers behavior bound to specific events.
All events must be explicitly bound to methods (no default or virtual methods). This is kind of a pain, but also gives you complete control and flexibility over the app's behavior.
Generally, it looks like a demanding, but very flexible, event-handling environment. You can consolidate event handling in a root context (base frame, MDI parent window, whatever) or handle things very locally (attaching event handlers to a subclassed button).
Layout
Again, very flexible. Looks like there's more than one way to control this:
- Absolute positioning, in pixels or units based on current/default text size
(like
ems
in CSS) - Layout constraints (rules for resolving conflicts between "sibling" widgets, frames, etc.
- Sizers, which are objects which sort of "influence" widgets. Not clear if an object can be under the influence of multiple sizers, or if so, how their effects are resolved.
- Grid-based layout (also uses sizers)
Boa and Zope
There's a remote debugger Zope Product that allows debugging of a live Zope app.
Also a Plone unit-test framework of some kind..? Ask Chris Calloway about this.
And apparently some of the Boa functionality (Zope tab) that... um... I'm not sure what this does exactly. Chris C. about this. He's pretty sure that it builds and launches a local instance of Zope (or Plone?) and debugs against it..?
Refined graphics rendering (found this later)
Check out matplotlib, a very nice rendering engine for charting and structured graphics. Screenshots here: http://matplotlib.sourceforge.net/screenshots.html
This can be used in interactive mode (though I have no idea if it's a credible Flash replacement). Recommended combination is probably matplotlib + wxPython + wxAgg (http://matplotlib.sourceforge.net/faq.html#WHICHBACKEND)
wxAgg provides an antialiased canvas, which looks much better IMO than the drawn graphics in wxPython.