The wxGC provides a GetNativeContext() method which returns a pointer to the native cairo_t structure (on wxGTK anyway). It is possible to install cairo/pycairo on Windows, in which case a cairo context could be constructed. The method demonstrated here only works with wxGTK. I've tested it using Python-2.5, wxPythonGTK-2.8.7.1 and pycairo-1.4.7. This wiki-page shows how this can be done.Ī few of the extra things you can do with cairo include switching anti-aliasing off/on (for performance reasons) and rendering to a host of other targets like SVG, PDF, Bitmap etc.īesides wxPython, this requires ctypes and pycairo. It would be nice to be able to draw on wx-windows using the cairo API via the python-cairo bindings (pycairo). wxGraphicsContext is nice 'n all, but cairo itself provides a lot more flexibility than is exposed in the wxGraphicsContext interface. On wxMSW, this uses GDIPlus calls for rendering, on wxGTK, cairo is used. WxPython has a new wxGraphicsContext ("wxGC") class (and related classes) which provide a nice, modern paths-based drawing API. Update: wxPython versions 2.8.9 and later now include the wx.lib.wxcairo module, which provides an easier means of cairo integration (including cross-platform support, for example).
0 Comments
Leave a Reply. |