I've got a preview build percolating through the build system as I type this, so if all goes well there will be a preview available for all of you to test in a few hours. Watch this list for the announcement.
The reason for this email is that I thought I would give you some highlights of the main new feature of this release. As you've probably guessed from my cryptic comments in some wxPython-users messages a week or two ago this release will provide some glue code to allow you to smoothly use the pycairo package in wxPython applications. There are more details in the CHANGE notes and in the library modules, but I thought that many in this group would be interested in some things that might not be obvious at first glance.
First, wx.lib.wxcairo is the glue module. It provides a function to create a cairo.Context that uses a window/client/paint/memory DC as the surface. (Hopefully I'll be able to add printer DCs to that list too...) Also functions to convert wx.Bitmaps to/from cairo.ImageSurfaces, and one that can extract the native innards of a wx.Font and call the cairo function for creating a native cairo.FontFace. See http://svn.wxwidgets.org/viewvc/wx/wxPython/branches/WX_2_8_BRANCH/wx/lib/wxcairo.py?revision=55616&view=markup
Next, I've implemented a wx.GraphicsContext-like API that uses wxcairo and pycairo. This let's us have an implementation of GraphicsContext that is totally consistent across platforms. It's not an exact match to the wxGC API, but close enough that if you are careful you can use the same code with either implementation. Of course since it's Python it's easy to add in some Python-isms along the way to make it a bit easier to use, and since it's Cairo it's not hard to give it some capabilities that wxGC doesn't have, like being able to fill text with a brush. See: http://svn.wxwidgets.org/viewvc/wx/wxPython/branches/WX_2_8_BRANCH/wx/lib/graphics.py?revision=55721&view=markup
BTW, I took the current wx.GC sample from the demo and ran it using wx.lib.graphics and compared timings. On Windows it looks like using cairo is about twice as fast as the GDI+ backed GraphicsContext, about 0.25 seconds vs. 0.11 seconds. On the other platforms the wx.GraphicsContext version is faster, but not by a great amount.
Finally, especially for Chris Barker, we now have a way to directly use a Python buffer object as the target of drawing operations and the source of bitmap data for drawing to the screen, with no extra copying of the pixel data to and from the buffer. See GraphicsBitmap.CreateFromBuffer in graphics.py.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I've got a preview build percolating through the build system as I type this, so if all goes well there will be a preview available for all of you to test in a few hours. Watch this list for the announcement.
I've got a preview build percolating through the build system as I type this, so if all goes well there will be a preview available for all of you to test in a few hours. Watch this list for the announcement.
First, wx.lib.wxcairo is the glue module. It provides a function to create
a cairo.Context that uses a window/client/paint/memory DC as the surface.
(Hopefully I'll be able to add printer DCs to that list too...) Also
functions to convert wx.Bitmaps to/from cairo.ImageSurfaces, and one that
can extract the native innards of a wx.Font and call the cairo function for
creating a native cairo.FontFace. See http://svn.wxwidgets.org/viewvc/wx/wxPython/branches/WX_2_8_BRANCH/wx/lib/wxcairo.py?revision=55616&view=markup
Next, I've implemented a wx.GraphicsContext-like API that uses wxcairo and
pycairo. This let's us have an implementation of GraphicsContext that is
totally consistent across platforms. It's not an exact match to the wxGC
API, but close enough that if you are careful you can use the same code with
either implementation. Of course since it's Python it's easy to add in some
Python-isms along the way to make it a bit easier to use, and since it's
Cairo it's not hard to give it some capabilities that wxGC doesn't have,
like being able to fill text with a brush. See: http://svn.wxwidgets.org/viewvc/wx/wxPython/branches/WX_2_8_BRANCH/wx/lib/graphics.py?revision=55721&view=markup
BTW, I took the current wx.GC sample from the demo and ran it using
wx.lib.graphics and compared timings. On Windows it looks like using cairo
is about twice as fast as the GDI+ backed GraphicsContext, about 0.25
seconds vs. 0.11 seconds. On the other platforms the wx.GraphicsContext
version is faster, but not by a great amount.
I have downloaded the latest pre-release of wxPython, then I went on this link:
To get the Windows binary for pycairo. After installation, in the
cairo directory I have the following files:
__init__.py
__init__.pyc
__init__.pyo
_cairo.pyd
But when I try to do a simple "import cairo" I get:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\Lib\site-packages\cairo\__init__.py", line 1, in <module>
from _cairo import *
ImportError: DLL load failed: The specified module could not be found.
Did you do anything in particular to get pycairo workingon Windows?
Thank you for the new pre-release and for all the work you are doing!
I've got a preview build percolating through the build system as I type this, so if all goes well there will be a preview available for all of you to test in a few hours. Watch this list for the announcement.
To get the Windows binary for pycairo. After installation, in the
cairo directory I have the following files:
__init__.py
__init__.pyc
__init__.pyo
_cairo.pyd
But when I try to do a simple "import cairo" I get:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\Lib\site-packages\cairo\__init__.py", line 1, in <module>
from _cairo import *
ImportError: DLL load failed: The specified module could not be found.
Did you do anything in particular to get pycairo workingon Windows?
You also need DLLs for cairo, libpng and zlib. I've put a copy of everything you need at Index of /cairo. Just extract the DLLs from the zip files and put them on your PATH someplace.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Next, I've implemented a wx.GraphicsContext-like API that uses wxcairo and pycairo.
very cool!
Finally, especially for Chris Barker, we now have a way to directly use a Python buffer object as the target of drawing operations and the source of bitmap data for drawing to the screen, with no extra copying of the pixel data to and from the buffer. See GraphicsBitmap.CreateFromBuffer in graphics.py.
gee thanks! I feel so special!
I'm looking forward to checking this out, and maybe integrating it with floatCanvas2 at some point -- Cairo has a few features that GCs do not.
Is there any chance in the future of including the needed Cairo stuff with the wxPython distribution? You know how folks feel about dependencies...
-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