Jimmy's Python Pages

This page is a collection of various Python goodies I've created. Everything here is covered by the MIT License. Please let me know if you have any questions or feedback by sending email to jimmy@retzlaff.com.

EasyDialogs for Windows 46691.0 - a lightweight port of the Macintosh EasyDialogs module
pyUnRAR 1.0 - a module that wraps the free UnRAR.dll.
X10 FireCracker Module for Python 1.0 - a module for turning electrical devices on/off
wxPython AGG Device Context Proof of Concept - using Anti-Grain Geometry in wxPython

wxPython AGG Device Context Proof of Concept

Zip Download - contains wxagg.py

Requires: Microsoft Windows, Python 2.4 (may work in 2.3, but I haven't tested it), wxPython 2.6, PIL, and aggdraw.

Fredrik Lundh has released the aggdraw module which allows the use of the Anti-Grain Geometry library to draw into PIL images. AGG is used by several projects including matplotlib and scipy.

For a while now I've been looking for a way to use AGG in my wxPython applications, but all the approaches I've looked into have required more time than I could afford to spend. This is the first time I've gotten as far as putting AGG rendered images on a wxPython window. The idea is to create a class (AggDC) derived from wx.DC that takes another DC as a parameter to __init__. All drawing done to the AggDC will be rendered using AGG and upon destruction will be copied to the underlying DC. So the only change to my code would be to change this:

def OnPaint(self, event):
    dc = wx.PaintDC(self)

to this:

def OnPaint(self, event):
    dc = AggDC(wx.PaintDC(self))

Here's a screenshot. The graphics on the left were drawn using an AggDC, the right with wx.PaintDC. Pay special attention to the diagonal line and the curved edges:

The zip file above contains the start of AggDC and the sample app pictured above. AggDC is not really far enough along to be terribly useful, it only has a few drawing primitives (CrossHair, DrawArc, DrawCircle, DrawEllipse, and DrawLine). Many of wx.DCs primitives would be very difficult to implement using Fredrik's aggdraw module - going directly to AGG's C++ code would probably be a more viable approach and might allow this to be more cross platform.

Anyway, I'd love to have a robust version of something like this. Hopefully somebody will get the time some day (maybe even me).


Here the colorful circles are shown blown up to show the difference, left is AGG, right is not: