Table Of Contents

Previous topic

wordwrap

Next topic

Pycairo_CAPI

This Page

phoenix_title wxcairo

This module provides some glue code that allows the pycairo package to be used for drawing direclty on wx.DCs. In cairo terms, the DC is the drawing surface. The CairoContextFromDC function in this module will return an instance of the pycairo Context class that is ready for drawing, using the native cairo surface type for the current platform.

This module requires the pycairo pacakge, and makes use of ctypes for fetching the pycairo C API and also for digging into the cairo library itself.

To use Cairo with wxPython you will need to have a few dependencies installed. On Linux and other unix-like systems you may already have them, or can easily get them with your system’s package manager. Just check if libcairo and pycairo are installed.

On Mac you can get Cairo from MacPorts or Fink. If you are also using MacPorts or Fink for your Python installation then you should be able to get pycairo the same way. Otherwise it’s real easy to build and install pycairo for the Python framework installation. Just get the source tarball from http://pypi.python.org/pypi/pycairo and do the normal ‘python setup.py install’ dance.

On Windows you can get a Cairo DLL from here:

You’ll also want to get the zlib and libpng binaries from the same page. Once you get those files extract the DLLs from each of the zip files and copy them to some place on your PATH. Finally, there is an installer for the pycairo pacakge here:


class_hierarchy Inheritance Diagram

Inheritance diagram for module wxcairo

Inheritance diagram of wxcairo


function_summary Functions Summary

BitmapFromImageSurface Create a wx.Bitmap from a Cairo ImageSurface.
ContextFromDC Creates and returns a Cairo context object using the wxDC as the
FontFaceFromFont Creates and returns a cairo.FontFace object from the native
ImageSurfaceFromBitmap Create an ImageSurface from a wx.Bitmap
voidp Convert a SWIGged void* type to a ctypes c_void_p

class_summary Classes Summary

Pycairo_CAPI  

Functions



BitmapFromImageSurface(surface)

Create a wx.Bitmap from a Cairo ImageSurface.



ContextFromDC(dc)

Creates and returns a Cairo context object using the wxDC as the surface. (Only window, client, paint and memory DC’s are allowed at this time.)



FontFaceFromFont(font)

Creates and returns a cairo.FontFace object from the native information in a wx.Font.



ImageSurfaceFromBitmap(bitmap)

Create an ImageSurface from a wx.Bitmap



voidp(ptr)

Convert a SWIGged void* type to a ctypes c_void_p