0

PyInstaller 误导性地为用户定义了包含 an 的标志,.icns但它实际上什么都不做,如文档所述:

-i FILE.ICO, -i FILE.EXE,ID, -i FILE.ICNS, --icon=FILE.ICO, --icon=FILE.EXE,ID, --icon=FILE.ICNS
If FILE is an .ico file, add the icon to the final executable. Otherwise, the syntax 'file.exe,id' to extract the icon with the specified id from file.exe and add it to the final executable. If FILE is an .icns file, add the icon to the final .app bundle on Mac OS X (for Mac not yet implemented)

所以那是相当绝望的。下一个最好的方法肯定是用我自己的替换默认的 PyInstaller 图标,当然。我在脚本中执行此操作:

pyinstaller -y --windowed  --name="foobar" --workpath="target/build" --distpath="target/dist" *.spec

# Update the icon: PyInstaller's -i switch is not implemented for Mac
cp "path/to/icon.icns" "target/dist/foobar.app/Contents/Resources/icon-windowed.icns"

但是,我发现以编程方式执行此操作会导致 Finder 感到困惑,因为它已经将应用程序注册为具有原始 Python 图标。然而,它找不到。因此,应用程序启动时根本没有图标。

如何正确设置图标?

4

1 回答 1

0

似乎 pyinstaller 的选项仅与创建规范文件有关。获得规范文件后,您应该编辑规范文件中的命令,而不是向命令行提供选项,这将被忽略。

要查看这些命令行选项在规范文件中的作用,您可以使用pyi-makespec脚本(随 PyInstaller 分发)。

于 2013-11-27T09:19:03.840 回答