Search code examples
pythonwindows-installercx-freezedistutilsshortcut-file

Python cx-freeze shortcut icon


I use cx-freeze to distrute an application by making a msi install file. In the setup.py script I specify the shortcut which needs to be placed on the desktop. However the shortcuts icon is blank. The setup.py contains the following code. What am I doing wrong?

import ...
....
shortcut_table = [
    ("DesktopShortcut",                                             # Shortcut
     "DesktopFolder",                                               # Directory_
     "PhotonFileEditor",                                            # Name
     "TARGETDIR",                                                   # Component_
     "[TARGETDIR]\PhotonEditor.exe",                                # Target
     None,                                                          # Arguments
     None,                                                          # Description
     None,                                                          # Hotkey
     "[TARGETDIR]photonsters.ico",                                  # Icon
     0,                                                             # IconIndex
     None,                                                          # ShowCmd
     "TARGETDIR",                                                   # WkDir
     )
]


# Now create the table dictionary
msi_data = {"Shortcut": shortcut_table}
#msi_data = {"Shortcut": shortcut_table, "Icon": icon_table}

# Change some default MSI options and specify the use of the above defined tables
bdist_msi_options = {'data': msi_data}

....

Solution

  • Thx, this solved my problem! A snippet of my code:

    Shortcuttable:

    shortcut_table = [
    ("DesktopShortcut", # Shortcut
     "DesktopFolder",   # Directory_
     "PhotonFileEditor",# Name
     "TARGETDIR",   # Component_
     "[TARGETDIR]\PhotonEditor.exe", # Target
     None,              # Arguments
     None,              # Description
     None,              # Hotkey
     "",                # Icon (Use 
     0,                 # IconIndex
     None,              # ShowCmd
     "TARGETDIR",                   # WkDir
     )
    ]
    

    Setup:

    setup (  name = "PhotonFileEditor",
             version = "0.1",
             author= "Photonsters",
             url="https://github.com/Photonsters",
             description = "Photon File Editor",
             options = {"build_exe": build_exe_options,"bdist_msi": bdist_msi_options},
             executables = [Executable(script="PhotonEditor.py",       
             base=base,icon="PhotonEditor.ico",)]
     )