简体   繁体   中英

How to add an icon to a cx_Freeze executable?

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
)

This is the output

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

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 .

Try with a valid .ico file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM