Library is successfully installed but here are few errors:
ctx = cairo.GraphicsContext.Create(mdc)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 915, in Create
ctx = wx.lib.wxcairo.ContextFromDC(dc)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 115, in ContextFromDC
drawable = voidp( dc.GetGdkDrawable() )
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 71, in voidp
return ctypes.c_void_p(int(ptr))
TypeError: int() argument must be a string or a number, not 'NoneType'
another one:
(python:2115): Gdk-CRITICAL **: gdk_cairo_create: assertion
`GDK_IS_DRAWABLE (drawable)' failed.
Library is installed but lots of errors and segfaults
First:
ctx = cairo.GraphicsContext.Create(mdc)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 915, in Create
ctx = wx.lib.wxcairo.ContextFromDC(dc)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 115, in ContextFromDC
drawable = voidp( dc.GetGdkDrawable() )
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 71, in voidp
return ctypes.c_void_p(int(ptr))
TypeError: int() argument must be a string or a number, not 'NoneType'
It seems to be working okay here with my tests. There have been a few changes recently with the GTK specific parts of the code in wxcairo.py, you may want to try getting the latest version from SVN. If that doesn't help then send us a sample that shows the problem.
···
On 2/10/10 8:32 AM, King wrote:
Here is one more and I think this one is causing crash.
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 1152, in SetFont
font = GraphicsFont.CreateFromFont(font, colour)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 413, in CreateFromFont
f._fontface = wx.lib.wxcairo.FontFaceFromFont(font)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 164, in FontFaceFromFont
fontface =
pycairoAPI.FontFace_FromFontFace(ctypes.c_void_p(fontfaceptr))
cairo.Error:<unknown error status>
python: /build/buildd/cairo-1.8.8/src/cairo-font-face.c:191:
cairo_font_face_destroy: Assertion `((*&(&font_face->ref_count)-
The function "_findCairoLib" in *NEW* wxcairo is not able to find
cairo libs and raising an error.
I have replaced "_findCairoLib" function from *OLD* library into *NEW*
one. At least now there is no missing library error.
Application is getting crashed raising an error:
Just to look at:
python: /build/buildd/cairo-1.8.8/src/cairo.c:87: _cairo_error:
Assertion `(status != CAIRO_STATUS_SUCCESS && status <=
CAIRO_STATUS_INVALID_WEIGHT)' failed.
Aborted
I am not getting anything else and it's difficult to create a sample
app to reproduce the problem.
Right now I am investigating more and get back to you ASAP.
import wx
import wx.lib.graphics as Cairo
import wx.lib.wxcairo as wxcairo
class DemoApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers() # called so a PNG can be saved
font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
font.SetPointSize(12)
# Render a bitmap using MemoryDC.
width, height = 100, 100
size = width, height
colorBitmap = wx.EmptyBitmapRGBA(size[0]+1, size[1]+1)#, 0, 0,
0, 0)
# Prepare the bitmap using cairo & cairo image surface
surface = wxcairo.ImageSurfaceFromBitmap(colorBitmap)
ctx = Cairo.GraphicsContext.CreateFromSurface(surface)
# Imagine this as a onDraw/onPaint function where you are
continuously setting
# different fonts and drawing texts using it.
ctx.SetFont(font, "blue")
ctx.SetFont(font, "blue")
ctx.SetFont(font, "blue")
ctx.SetFont(font, "blue")
ctx.SetFont(font, "blue")
Sorry I forgot to mention that change, see wxTrac has been migrated to GitHub Issues - wxWidgets. I'm working on a fix that will still solve the problem the patch was intended to fix, but also fall back to the old way in the other cases.
Ok, that's done and the crashing bug is fixed too. The refcount on the fontface object needed to be incremented.