Search code examples
pythoniconscx-freeze

Add icon to a cx_Freeze script


How to add an icon to an executable made with cx_Freeze? I was looking for a solution on google & stackoverflow, but I couldn't find any.

This is my setup.py

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"includes": ["tkinter"]}

# GUI applications require a different base on Windows (the default is for
# a console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "YouTube-Video-Downloader",
        version = "0.1",
        description = "",
        options = {"build_exe": build_exe_options},
        executables = [Executable("app.py", base=base)])

Solution

  • You can add an icon to your executable using the icon argument of the Executable:

    setup(  name = "YouTube-Video-Downloader",
            version = "0.1",
            description = "",
            options = {"build_exe": build_exe_options},
            executables = [Executable("app.py", base=base, icon="path_to_icon_file")])
    

    The given icon file needs to be a valid icon file for Windows. See also the cx_Freeze documentation.