gpt4 book ai didi

python - 将 gpointer 与 Python 和 GObject 自省(introspection)一起使用

转载 作者:行者123 更新时间:2023-12-04 18:08:56 25 4
gpt4 key购买 nike

我正在学习 Python 和 Gtk 3,使用 GObject 自省(introspection)。我已经做了一些样本,并且开始了解它是如何工作的。但是有一件事我不明白,我如何传递 gpointer 参数?

我尝试使用接收缓冲区的函数(使用 gpointer),但我总是以这条消息结束:

无法将属性“pixels”的值从 LP_c_ubyte 转换为 gpointer

(LP_c_ubyte 是我最后一次尝试,但我已经证明了很多类型)

最佳答案

您不能在 GObject 自省(introspection)中传递指针。如果内省(introspection)函数是你自己写的,那么你应该 annotate您的参数文档,例如 (array length=buflen),其中 buflen 是给出缓冲区长度的参数的名称。有关详细信息,请参阅链接页面。

如果该函数位于不是您自己编写的库中,请在 API 中四处寻找更适合内省(introspection)的函数,或者向该库提交错误。使用裸 gpointer 的 API 甚至不应该暴露给 Python。

关于python - 将 gpointer 与 Python 和 GObject 自省(introspection)一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19464562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com