【问题标题】:Adding an icon for my exe file with CX_freeze使用 CX_freeze 为我的 exe 文件添加图标
【发布时间】:2020-04-08 05:08:56
【问题描述】:

我正在使用 cx_freeze 将 .py 文件转换为 .exe 文件。哪个有效,但我似乎无法更改它,以便我的 .exe 文件具有我拥有的自定义图标。这是我到目前为止所尝试的: '''

import sys
import os
from cx_Freeze import setup, Executable

sys.path.append(os.path.abspath("./src/"))
sys.path.append(os.path.abspath("./src/gui/rc/"))

**Dependencies are automatically detected, but it might need fine tuning.**

buildOptions = {
    "packages": ["src.gui",
                 "src.qt_models",
                 "src.data",
                 "src.libs",
                 "src.tguiil",
                 "src.graphics"
                 ],
    "includes": ["scipy.sparse.csgraph._validation",
                 "scipy.ndimage._ni_support",
                 "scipy._distributor_init"
                 ],
    "include_files": ["database/"],
    "excludes": []
}

installOptions = {}

bdistOptions = {}

base = None

** Uncomment for GUI applications to NOT show cmd window while running.**
if sys.platform =='win32':
    base = 'Win32GUI'

executables = [
    Executable(script = 'src/facile.py', base=base, targetName = 'facile.exe', icon = 'facade_logo.ico')
]

setup(name='Facile',
      version = '1.0',
      description = 'A platform for generating Python APIs used to control graphical user interfaces.',
      options = {
          "build_exe": buildOptions,
          "install_exe": installOptions,
          "bdist_msi": bdistOptions,
      },
      executables = executables)

'''

我不知道可能出了什么问题。

【问题讨论】:

    标签: python icons executable cx-freeze


    【解决方案1】:

    想通了!只需要添加文件的相对路径并添加 distutils 作为一个包来处理外部依赖:

    '''

    buildOptions = {
        "packages": [
                    # Facile sub-packages
                     "src.gui",
                     "src.qt_models",
                     "src.data",
                     "src.libs",
                     "src.tguiil",
                     "src.graphics",
    
                    # External dependencies
                     "distutils"
                     ],
    

    '''

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-06
      • 1970-01-01
      • 2021-02-09
      • 2011-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多