Python cx冻结快捷方式图标

Python cx冻结快捷方式图标,python,windows-installer,cx-freeze,distutils,desktop-shortcut,Python,Windows Installer,Cx Freeze,Distutils,Desktop Shortcut,我使用cx freeze通过生成msi安装文件来分发应用程序。在setup.py脚本中,我指定了需要放置在桌面上的快捷方式。但是,快捷方式图标为空。setup.py包含以下代码。我做错了什么 import ... .... shortcut_table = [ ("DesktopShortcut", # Shortcut "DesktopFolder",

我使用cx freeze通过生成msi安装文件来分发应用程序。在setup.py脚本中,我指定了需要放置在桌面上的快捷方式。但是,快捷方式图标为空。setup.py包含以下代码。我做错了什么

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}

....
  • 您是否尝试过:

    • 图标
      参数添加到您的
      可执行文件
    • 删除
      快捷方式表的
      目标
      中的反斜杠
      ,并删除
      图标
      图标索引

      import ...
      
      ....
      shortcut_table = [
          ("DesktopShortcut",                                             # Shortcut
           "DesktopFolder",                                               # Directory_
           "PhotonFileEditor",                                            # Name
           "TARGETDIR",                                                   # Component_
           "[TARGETDIR]PhotonEditor.exe",                                 # Target
           None,                                                          # Arguments
           None,                                                          # Description
           None,                                                          # Hotkey
           None,                                                          # Icon
           None,                                                          # 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}
      
      executables = [Executable(....,
                                icon='photonsters.ico')]
      
      ....
      
      setup(....,
            executables=executables)
      
  • 您是否检查了图标文件
    phononsters.ico
    是否在生成步骤后的
    build\u dir
    目录中


  • Thx,这解决了我的问题!我的代码片段:

    快捷键:

    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 (  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",)]
     )
    

    不太确定。但既然已经两天没有回复了,你有没有检查过这行不需要反斜杠?“[TARGETDIR]\photonsters.ico”。此外,“Icon”字段实际上是Windows Installer文档中的“Icon”,即它是名为“Icon”的表中的外键。