My current use case is related to some code that I had originally written
using Objective-C and the Cocoa frameworks  that enabled the user to explore
some of the properties of Bezier and spline curves.

Now that I am studying Python, I thought it would be an instructive exercise
to implement the above code in Python.

I started by implementing the model part of the above code in Python, and so
far that has gone pretty well.

Now it is time to implement the graphics and a GUI, and I am looking for the
following:


   - APIs that draw cubic Bezier curves ( or several cubic Bezier curves
   joined together ) ideally without requiring the programmer to implement a
   linear approximation of the curves (and it looks like wxPython is quite
   suitable)
   - GUI functionality that responds to mouse down, mouse moved, and mouse
   up events, so that the user can drag around control points ( represented by
   circles on the canvas ) and thus modify the curve.

I have just started to explore wxPython today, so this is all still new.  I
had trouble getting the Python 2.7 wx to work, but have downloaded and
installed the Python 2.6 version, which is working.

On Thu, Dec 9, 2010 at 10:40 AM, Christopher Barker
<[email protected]>wrote:

> On 12/9/10 9:15 AM, Richard Fuhr wrote:
>
>> Upon further investigation, it looks like wxPython has an API here (
>>
>> http://www.wxpython.org/docs/api/wx.GraphicsPath-class.html#AddCurveToPoint
>> ) that seems to closely resemble the curveToPoint method (from
>> Objective-C/Cocoa) for drawing cubic Bezier curves.  So perhaps wxPython
>> would be a better approach than Tkinter for conveniently drawing Bezier
>> curves.
>>
>
> Yup -- the relatively new wxGraphicsContext is a pretty powerful solution.
> However, it doesn't have many of the other nifty features of the Tk Canvas.
>
> I wrote a higher-level Canvas on top of the older wxDC classes:
>
> http://trac.paulmcnett.com/floatcanvas
>
> It doesn't have a real Bezier spline built in, rather then older, less
> flexible wxDC spline. However, you could add it:
>
> http://trac.paulmcnett.com/floatcanvas/wiki/SmoothLines
>
> Or you could use the newer, but less tested FloatCanvas2 that is built on
> GraphicsContext:
>
>
> http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/branches/FloatCanvas/SOC2008_FloatCanvas/floatcanvas2/
>
> wx also has a wrapper around Cairo, that provides all of Cairo's rending
> abilities.
>
> Of course, there are other reasons to choose wx or tk as well, which may
> (or may not) be more compelling.
>
>  -- what is your use-case?
>
>
> -Chris
>
>
>
>
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> [email protected]
>

Reply via email to