Search code examples
pythoncx-freeze

How To add icons to exe using Cx_Freeeze


I havs the setup.py file which is used to build my program. I wanted to know how to add an icon to the final 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")])

Solution

  • Just add icon=icon.ico in Executable() like this:

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