如何在cx_Freeze可执行文件中添加图标? [英] How to add an icon to a cx_Freeze executable?
问题描述
我已经看过解决此问题的上一个问题,并且我确信我已经正确实现了代码.每当我在安装脚本上运行"build_msi"命令时,它只会创建一个内部为空的构建文件夹.每当我从Executable函数中删除icon参数时,安装程序都会正确构建.这是代码.
I have looked at previous question that address this issue and I am very sure I have implemented the code correctly. Whenever I run the "build_msi" command on my setup script it only creates a build folder that is empty inside. Whenever I remove the icon parameter from the Executable function the installer builds correctly. This is the code.
from cx_Freeze import Executable, setup
executables = [Executable("FlappyBird.py", base = 'Win32GUI', shortcutName = 'Flappy Bird', shortcutDir = 'DesktopFolder', icon = 'Icon.ico')]
Packages = ['pygame']
Options = {
'build_exe': {
'packages': Packages,
'include_files': ['BackgroundBottom.png', 'BackgroundTop.png', 'BottomPipe.png', 'FlappyBirdFlat.png', 'TopPipe.png']
},
}
setup(
name = "Flappy Bird",
options = Options,
executables = executables
)
这是输出
running bdist_msi
running build
running build_exe
creating directory build\exe.win-amd64-3.6
copying C:\Program Files\Python36\lib\site-packages\cx_Freeze\bases\Win32GUI.exe -> build\exe.win-amd64-3.6\FlappyBird.exe
copying C:\Program Files\Python36\python36.dll -> build\exe.win-amd64-3.6\python36.dll
推荐答案
您的 Icon.ico
可能不是有效的 .ico
文件.我可以通过使用例如重命名为 Icon.ico
的空文本文件来重现您描述的行为.
Your Icon.ico
is probably not a valid .ico
file. I can reproduce the behavior you describe by using for example an empty text file renamed to Icon.ico
.
尝试使用有效的 .ico
文件.
这篇关于如何在cx_Freeze可执行文件中添加图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!