Using Cairo Regions in python with gi.repository
Asked Answered
L

1

6

I can't seem to get cairo regions working in within using the gintrospection.

For example

from gi.repository import cairo

 reg = cairo.Region()

will give me

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError

and trying to get a region from Gdk.get_clip_region() will give me

    return info.invoke(*args)
TypeError: Couldn't find conversion for foreign struct 'cairo.Region'

What obvious thing am I missing? I can't find a way to iniatilize the library, and can't imagine you would need to for regions which seem like a simple struct. I don't know why gdk can't find the cairo types, and am not aware if I"m supposed to show it the way somehow.

Loyola answered 26/5, 2011 at 4:19 Comment(1)
Your not alone it does this for me to. I think it's a bug, where someone has overlooked a couple of things when writing the gir xml definition files. It'll probably get fixed if it hasn't already, in future releases.Aberdeen
R
6

Apparently you need to use the regular cairo bindings, even when you use introspection for everything else.

So just import cairo.

(I'm not sure why gi.repository.cairo exists...)

And the "Couldn't find conversion" error will go away when you have all the necessary libraries (e.g. on Ubuntu you need the python-gi-cairo package in addition to python-cairo (or the equivalent python3 packages)).

Religieuse answered 14/7, 2012 at 2:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.