在 python 中通过 gi.repository 使用开罗区域
我似乎无法让开罗地区在其中工作 使用 gintrospection。
例如
from gi.repository import cairo
reg = cairo.Region()
会给我
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
MemoryError
,尝试从 Gdk.get_clip_region() 获取一个区域会给我
return info.invoke(*args)
TypeError: Couldn't find conversion for foreign struct 'cairo.Region'
我错过了什么明显的东西?我找不到初始化库的方法,并且无法想象您需要对看起来像简单结构的区域进行初始化。我不知道为什么 gdk 找不到 cairo 类型,也不知道我是否应该以某种方式显示它。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,即使您对其他所有事情都使用内省,您也需要使用常规的 cairo 绑定。
所以只需
导入 cairo
即可。(我不确定为什么
gi.repository.cairo
存在...)当你拥有所有必要的库时,“无法找到转换”错误就会消失(例如在Ubuntu上你需要除了
python-cairo
(或等效的 python3 软件包)之外,还有python-gi-cairo
软件包。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 topython-cairo
(or the equivalent python3 packages)).