Plug-In Drawing, Does Little Else
PIDDLE is a Python module
for creating two-dimensional graphics in a manner that is both cross-platform
and cross-media; that is, it can support screen graphics (e.g. QuickDraw,
Windows, Tk) as well as file output (PostScript, PDF, GIF, etc.). It makes
use of the native 2D drawing calls of each backend, for maximum efficiency
and quality. It works by defining a base class (piddle.Canvas) with methods
for all supported drawing primitives. A particular drawing context is provided
in the form of a derived class. PIDDLE applications will be able to automatically
select an appropriate backend for the user's environment.
[The most up-to-date version of this document can be found
via the Piddle home page at
PIDDLE is beginning beta testing. It should be stable now, though
there may be a few bugs still lurking here or there -- if you find any,
please send email to the PIDDLE mailing list at
The latest stable
PIDDLE distribution is available from our Source Forge download
here. You may also want to look at CVS access and other
information for developers if you want the latest experimental
As of 10 February 2000, the current release is 1.0.b1 --
see the version history to see
Please note that PIDDLE requires Python 1.5.2, because it uses
the "extend" list method, which is not available in older versions of Python.
The standard distribution includes the following back-end renderers:
 piddleTK does not yet support drawing of rotated strings.
The following backends are in various stages of development, and not
yet part of the standard distribution.
 winpiddle's string drawing is having some trouble with size
and color attributes; also, the text background is not transparent as it
should be. Unclear whether rotated strings are supported yet.
 piddleGTK doesn't yet draw rotated strings, but it is planned.
PIDDLE is designed for vector graphics -- i.e., drawing of primitives such
as lines and ellipses, rather than manipulation of individual pixels. Generally,
one creates a PIDDLE drawing in three steps:
Note that while PIDDLE is easiest to use in a noninteractive mode -- i.e.,
simply generating charts, pictures, or other static displays -- some backends
support callback methods invoked when the mouse moves over or clicks on
the drawing. This allows for some graphical interaction with the user.
instantiate a class derived from piddle.Canvas
call drawing methods on that object, such as drawLine or drawString
flush the canvas's buffer (i.e., update the file, screen, or whatever)
Creating a new PIDDLE backend is relatively easy. You must create a class
derived from piddle.Canvas, and instantiate at least the following methods:
All other drawing methods will have default implementations in terms of
the functions above. However, you may wish to also override other drawing
methods for the sake of efficiency or quality.
In addition, information specific to individual backends are placed in the docs/notes* directories
More examples are included with the distribution in the examples directory and in
piddletest.py, a file which allows you to select any test, and pair it with any
standard backend renderer.
|This example illustrates a hodgepodge of
PIDDLE drawing commands, including lines, curves, polygons, arcs, roundrects,
and rotated text. The graphic shown here was rendered with the
backend; other backends may vary, especially in the appearance of the
|This spectrum chart is actually a useful
program; I needed to generate a spectrum for a scientific application,
and this is the PIDDLE program I used to do it. In this program, I defined
a factory function 'makeCanvas' at the top of the program to create the
canvas. To use a backend other than QuickDraw, you'll only need to modify
|A string test module puts PIDDLE's font
and string handling through the paces. It illustrates the standard fonts
which every backend should be able to understand (and hopefully display).
|A string rotation test module exercises
the drawing of rotated strings at a variety of angles (in rainbow colors,
no less). Example output is shown for both QuickDraw and PIL. Note that
the two have somewhat different ideas about how big a 12-point (default)
font should be; this sort of discrepancy is inevitable, at least for now.
Credits & Feedback
PIDDLE was initially designed and implemented by a small international
team of Python coders. There is a mailing list for discussion of PIDDLE
To get your feedback to the list send email to