Python cxfreeze快捷方式图标

2024-04-25 17:35:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用cx freeze通过生成msi安装文件来分发应用程序。在设置.py脚本我指定需要放在桌面上的快捷方式。但是快捷方式图标是空白的。这个设置.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}

....

Tags: thepynone应用程序datatableshortcutoptions
2条回答

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

设置:

^{pr2}$
  1. 您是否尝试过:

    • icon参数添加到Executable中?在
    • 删除shortcut_tableTarget中的反斜杠,并删除Icon和{}项?在

      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)
      
  2. 在构建步骤之后,您是否检查了图标文件photonsters.ico是否存在于build_dir目录中?

相关问题 更多 >