cx freeze set custom .exe图标

时间:2017-04-11 21:29:57

标签: python-3.x cx-freeze

我正在使用cx_freeze将.py文件转换为.exe文件。我当前的安装文件正在运行,但我似乎无法更改它,以便我的.exe文件具有我自己制作的自定义图标。我尝试了几种不同的方式,但似乎没有一种方法可行。任何建议都会非常有帮助。谢谢你的时间。

尝试一次

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)])

尝试两次

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 个答案:

答案 0 :(得分:0)

此方法应该有效:

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])