Dinu Gherman wrote:
Frederik Lundh
seems to have abandoned his efforts to port DrawBot to Windows [4]
due to its "overforking disease."
Well, if you want something cross-platform, maybe the wxPython
FloatCanvas (written by me) would serve you well.
What I like about it (and why I wrote it) are four key features:
Generalized floating point coordinates: use whatever coordinate system
you like, and it will scale everything for you. It even supports a
limited projection option (I include a flat-earth projection for doing
simple maps)
Object Canvas: Add objects to the Canvas, then those objects can be
removed, properties changed, whatever.
Zooming, Panning, etc.
Event binding to Mouse events on the Canvas.
I even wrote a little demo that duplicates a DrawBot demo I saw
somewhere. I've enclosed it. It should work with recent versions of
wxPython. It does create an ugly Yellow. Can someone who better
understands RGB fix that?
By the way, you can use FloatCanvas with wxPython to generate PNGs, etc,
without ever bringing up a Window, though the windowing system does need
to be there, which I'm pretty sure it always is on OS-X.
Note that FloatCanvas needs Numeric. The versions on pythonmac.org work
fine.
I have plans to put in a better rendering engine (maybe Agg), and in the
process separate the rendering engine from wx, so that it could be used
for non-GUI work without wx. No guarantee about when that might happen,
however.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
[EMAIL PROTECTED]
#!/usr/bin/env pythonw2.4
import wx
from math import *
try: # see if there is a local FloatCanvas to use
import sys
sys.path.append("../")
from floatcanvas import NavCanvas, FloatCanvas
print "Using local FloatCanvas"
except ImportError: # Use the wxPython lib one
from wx.lib.floatcanvas import NavCanvas, FloatCanvas
print "Using installed FloatCanvas"
class DrawFrame(wx.Frame):
"""
A frame used for the FloatCanvas Demo
"""
def __init__(self,parent, id,title,position,size):
wx.Frame.__init__(self,parent, id,title,position, size)
# Add the Canvas
Canvas = NavCanvas.NavCanvas(self,-1,(500,500),
ProjectionFun = None,
Debug = 0,
BackgroundColor = "White",
)
self.Canvas = Canvas
self.Show(True)
self.MakePic()
return None
def MakePic(self):
Canvas = self.Canvas
phi = (sqrt(5) + 1)/2 - 1
oradius = 10.0
for i in xrange(0,720,1):
radius = 1.5 * oradius * sin(i * pi/720)
Color = (255*(i / 720.), 255*( i / 720.), 255 * 0.25)
x = oradius + 0.25*i*cos(phi*i*2*pi)
y = oradius + 0.25*i*sin(phi*i*2*pi)
Canvas.AddCircle((x,y),
radius,
LineColor = "Black",
LineWidth = 2,
FillColor = Color,
)
self.Canvas.ZoomToBB()
app = wx.PySimpleApp()
DrawFrame(None, -1, "FloatCanvas Demo App", wx.DefaultPosition, (700,700) )
app.MainLoop()
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig