python - 关于 Python 可执行文件中缺少 GTK 图标的警告

标签 python gtk pygtk pyinstaller

在我使用 Python 和 PyGTK 编写的可执行应用程序中,弹出一个 FileChooserDialog 给我这个警告:

GtkWarning: Could not find the icon 'gtk-file'.
The 'hicolor' theme was not found either, perhaps you need to install it.
You can get a copy from:
        http://icon-theme.freedesktop.org/releases

该链接将我带到一个似乎是为 Linux 编写的存档。这个警告不会阻止我的程序运行,但它很烦人,我认为它让我的用户感到困惑。当我从源代码运行应用程序时不会发生这种情况,只有当我首先使用 pyinstaller 将其构建为可执行文件时才会发生。有谁知道如何找到这个图标?

最佳答案

我解决了,但是……不合逻辑……我想。

理论上,pygtk 应该默认嵌入完整的图标集,所以真正奇怪的是“为什么要记录这些警告?”。

解决方案(适用于我的四个项目):

  1. 在项目的根目录中,应该有一个share 文件夹(如果没有,请创建它),您必须创建这些额外的子文件夹:

    YourProjectRoot/share/icons/hicolor/

  2. 下载 official binary icon theme for gnome (一个 12 MB 的 ZIP 文件)

  3. 解压存档,在 gnome-icon-theme_2.24.0-1_win32.zip/share/icons/gnome/ 中找到文件 index.theme 并将其复制到您创建的 hicolor/ 文件夹。

就这样

关于python - 关于 Python 可执行文件中缺少 GTK 图标的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12642804/

相关文章:

python - gtk 中的 alloc_color() 有什么意义?

python - rpy2 无法加载外部库

python - 尝试返回赋值的值时出现语法错误

c - Gtk+/X11 : semitransparent windows with and without composite managers?

python - PyGTK如何单击按钮并在弹出窗口中打开文件

python - PyGTK TreeView 中的粗体/非粗体行

python - tensorflow 。非线性回归

Raspberry Pi 上的 Python 脚本在执行 mysql 语句时出现错误

c - 为什么在 C 语言的 Ubuntu Linux 上 pango_layout_get_pixel_size 略有错误

python - 在 Windows 上安装 PyGObject