Using Cairo Regions in python with gi.repository

こ雲淡風輕ζ 提交于 2019-12-23 10:07:37

问题


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.


回答1:


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)).



来源:https://stackoverflow.com/questions/6133622/using-cairo-regions-in-python-with-gi-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!