如何使用 Cx_Freeeze 将图标添加到 exe

How To add icons to exe using Cx_Freeeze

我有 setup.py 文件用于构建我的程序。我想知道如何将图标添加到最终的 exe

import sys
from cx_Freeze import setup, Executable

setup(
name = "Calculator",
version = "3.7.8",
description = "Simple Calculator",
executables = [Executable("Calculator.py", base = "Win32GUI")])

只需在 Executable() 中添加图标=icon.ico,如下所示:

from cx_Freeze import setup, Executable

target = Executable(
    script="Calculator.py",
    base="Win32GUI",
    compress=False,
    copyDependentFiles=True,
    appendScriptToExe=True,
    appendScriptToLibrary=False,
    icon="icon.ico"
    )

setup(
    name="Calculator",
    version="3.7.8",
    description="Simple Calculator",
    author="Hanzalah Ravat",
    options={"build_exe": options},
    executables=[target]
    )