GTK - Python Pixbuf From List



我将图标数据放入Python列表中。如何将此图标数据导入pixbuf?我在这个来源找不到它。

这是我得到的图标数据代码:

from gi.repository import Gio
apps = Gio.AppInfo.get_all()
icon = apps[0].get_icon()
print(icon)

Python 3,GTK3,操作系统:类似Debian的Linux。

我找不到如何将Gio.AppInfo图标放入pixbuf,但我用另一种方法解决了问题。

我在/usr/share/applications/位置找到了桌面应用程序文件。我可以通过读取它的.desktop文件来获取特定的应用程序图标。最后,我可以通过使用new_from_file()命令将图标获取到pixbuf中。

在我的机器中工作的代码是:

#!/usr/bin/python3
from gi.repository import Gio
apps = Gio.AppInfo.get_all()
icon = apps[0].get_icon().to_string()
print (icon)

以下也适用:

#!/usr/bin/python3
from gi.repository import Gio
apps = Gio.AppInfo.get_all()
icon = apps[0].get_icon()
print (Gio.ThemedIcon.get_names(icon))

最新更新