【问题标题】:WIMP theme not found - only when bundling with PyInstaller (Windows)未找到 WIMP 主题 - 仅在与 PyInstaller (Windows) 捆绑时
【发布时间】:2023-06-13 00:14:01
【问题描述】:

我使用 Glade 和 PyGTK(在 Windows 7 上)构建了一个简单的应用程序。从 Python 解释器来看,一切都很好。但是,与 PyInstaller 捆绑后,我收到以下警告:

 GtkWarning: Could not find the icon 'gtk-missing-image'. The 'hicolor' theme was not found either, perhaps you need to install it.

而且 GUI 看起来很丑……

这是两次运行的屏幕截图。

编辑

我在 GTK 安装中找到了“hicolor”主题文件。它似乎只包含图标。因此,这不是一般外观的原因,而只是标题栏中可以出现的不同图标。

【问题讨论】:

    标签: python pygtk pyinstaller


    【解决方案1】:

    解决了问题,基于http://www.pyinstaller.org/ticket/14

    但是,他们的解决方案对我不起作用,所以我对其进行了一些修改。

    将此添加到spec 文件中:

    a.datas += [('gtkrc', r'C:\Python27\Lib\site-packages\gtk-2.0\runtime\share\themes\MS-Windows\gtk-2.0\gtkrc', 'DATA')]
    a.binaries += [(r'lib\gtk-2.0\2.10.0\engines\libwimp.dll', r'C:\Python27\Lib\site-packages\gtk-2.0\runtime\lib\gtk-2.0\2.10.0\engines\libwimp.dll', 'BINARY') ]
    

    这个给__init__

    gtk.rc_add_default_file(resource_path("gtkrc"))
    

    现在看起来不错...(顺便说一句,它没有解决关于丢失图标和“hicolor”主题的原始警告,但这不那么重要了。)

    【讨论】: