我知道这个问题在这个论坛上已经被问过很多次了,但是当我使用 cx_Freeze 将我的 PyQt 应用程序构建到一个工作的 exe 文件中时,我真的无法让我的应用程序图标工作。
我已将 Qt 图像插件(qico4.dll、qjpeg4.dll 等)复制到 appdir/imageformats 和 appdir 中。我也将 qt.conf 复制到那些目录中。改变了它的路径,什么也没有。这是在某些主题中提出的。
我尝试使用 setup.py-file 和不使用它以多种方式设置图标选项。
我尝试使用 qt designer 创建资源文件并进行转换。我尝试使用 qt designer 将图标设置到我的主窗口。还是什么都没有。
现在这是我的 setup.py 脚本:
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
executables = [
Executable(
"main.py",
base = base,
icon = "icon_64x64.ico",
appendScriptToExe = True,
appendScriptToLibrary = False,
targetName = "MyApp.exe")
]
buildOptions = dict(
create_shared_zip = False)
setup(
name = "MyApp",
version = "1.0",
options = dict(build_exe = buildOptions),
executables = executables)
最佳答案
应用程序图标不是 Qt 管理的东西 - 它嵌入到 exe 文件中供操作系统读取。
检查 icon_64x64.ico
是否存在于您运行 setup.py
的同一文件夹中,并且它是一个有效的 ico 文件。为了比较,here's与图标一起使用的 setup.py。
关于image - 使用 cx_Freeze 构建时,图标未显示在 PyQt 应用程序 exe 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15117772/