在带有gi.repository的python中使用开罗地区 [英] Using Cairo Regions in python with gi.repository

查看:145
本文介绍了在带有gi.repository的python中使用开罗地区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法让开罗地区参与其中 使用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绑定.

所以只是import cairo.

(我不确定为什么gi.repository.cairo存在...)

当您拥有所有必需的库时,找不到转换"错误将消失(例如,在Ubuntu上,除了python-cairo(或等效的python3软件包)之外,还需要python-gi-cairo软件包)./p>

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.

解决方案

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

这篇关于在带有gi.repository的python中使用开罗地区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆