我知道这个问题在这个论坛上已经被问了很多次,但是当我使用cx_Freeze将我的PyQt应用程序打包成可执行文件时,我真的无法让我的应用程序图标有效工作。
我已经将Qt图像插件(qico4.dll,qjpeg4.dll等)复制到appdir/imageformats和appdir中。我也将qt.conf复制到这些目录中。改变了路径,但没有什么效果。这是在某个话题中建议的。
我尝试了多种方式设置setup.py文件中的icon选项,也尝试了不使用该文件进行设置。
我试图使用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)