.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2017 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. module:: wx.lib.wxcairo

.. currentmodule:: wx.lib.wxcairo

.. highlight:: python



.. _wx.lib.wxcairo:

==========================================================================================================================================
|phoenix_title|  **wx.lib.wxcairo**
==========================================================================================================================================

This package provides some glue code that allows the Cairo library to draw
directly on :class:`wx.DC` objects, convert to/from :class:`wx.Bitmap`
objects, etc. using either the PyCairo or the newer cairocffi Cairo wrappers.
In Cairo terms, the DC is the drawing surface.  The ``CairoContextFromDC``
function in this module will return an instance of the Cairo Context class
that is ready for drawing, using the native cairo surface type for the current
platform.

.. note:: Be sure to import ``wx.lib.wxcairo`` before importing the ``cairo``
   module.

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 either cairocffi or pycairo packages are installed.

On Mac you can get Cairo from MacPorts or similar tools.  Make sure that
the quartz option is turned on so those Mac-specific APIs will be included in
the Cairo library when it is built.  You can then use ``pip install cairocffi``
to get the Python wrappers.

On Windows a copy of the Cairo and related DLLs are included with wxPython
inside the wx package folder.  These files were extracted from the GTK runtime
installers found at the following URLs. You can replace those DLLs with others
if you choose, or you can cause the wx_cairocffi module to use DLLs from some
other location by setting the CAIRO environment variable.

    32bit: http://gtk-win.sourceforge.net/home/index.php/Main/Downloads
    64bit: https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer



Functions
------------

.. function:: BitmapFromImageSurface(surface)

   Create a :class:`wx.Bitmap` from a Cairo ``ImageSurface``.


.. function:: ContextFromDC(dc)

   Creates and returns a ``cairo.Context`` object using the :class:`wx.DC` as
   the surface.  (Only window, client, paint and memory DC's are allowed at
   this time.)


.. function:: FontFaceFromFont(font)

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


.. function:: ImageSurfaceFromBitmap(bitmap)

   Create a Cairo ``ImageSurface`` from a :class:`wx.Bitmap`


