cx freeze set custom .exe icon

拜拜、爱过 提交于 2019-12-11 04:24:36

问题


I am converting a .py file to a .exe file using cx_freeze. My current setup file is working but I can not seem to change it so that my .exe file has the custom icon I have made. I have tried a few different ways and none of them seem to be working. Any advice would be very helpful. Thank you for your time.

Attempt one

import sys
from cx_Freeze import setup, Executable

include_files = ['autorun.inf']

base = None

if sys.platform == "win32":
    base = "Win32GUI"

setup(name = "Calculator",
        version = "0.1",
        description = "Simple Calculator",
        options = {'build_exe':{'include_files':include_files, 
                   'icon':'icon.ico'}},
        executables=[Executable("main.py", base = base)])

Attempt Two

import sys
from cx_Freeze import setup, Executable

include_files = ['autorun.inf']

base = None

if sys.platform == "win32":
    base = "Win32GUI"

setup(name = "Calculator",
        version = "0.1",
        description = "Simple Calculator",
        options = {'build_exe':{'include_files':include_files}},
        executables=[Executable("main.py", base = base, icon = 'icon.ico')])

回答1:


This method should work:

import sys
from cx_Freeze import setup, Executable

include_files = ['autorun.inf']

base = None

if sys.platform == "win32":
    base = "Win32GUI"

exe = Executable(script='main.py', base = base, icon='icon.ico')


setup(name = "Calculator",
        version = "0.1",
        description = "Simple Calculator",
        options = {'build_exe':{'include_files':include_files}},
        executables = [exe])


来源:https://stackoverflow.com/questions/43356518/cx-freeze-set-custom-exe-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!