我在将脚本传递给可执行文件时遇到了一些复杂的问题,但我终于设法做到了。主要问题是 PyInstaller 不会将图像加载到 GUI。
它应该是这样的:
这是它的样子:
而且我似乎找不到问题,这是 .spec 文件:
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'programa.py'],
pathex=['img', 'C:\\Users\\Poblet\\ManGet\\HeyMang\\pyinstaller'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build\\pyi.win32\\Hey Mang!', 'Hey Mang!.exe'),
debug=False,
icon='heymang.ico',
strip=False,
upx=True,
console=False )
coll = COLLECT( exe,
Tree('C:\\Users\\Poblet\\ManGet\\HeyMang\\pyinstaller\\img'),
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name=os.path.join('dist', 'Hey Mang!'))
app = BUNDLE(coll,
name=os.path.join('dist', 'Hey Mang!.app'))
它应该抓取这些图像,就像它在这里所说的那样:
Warnings written to C:\Users\Poblet\ManGet\HeyMang\pyinstaller\Hey Mang!\warnHey Mang!.txt
checking PYZ
rebuilding outPYZ1.toc because outPYZ1.pyz is missing
building PYZ outPYZ1.toc
checking PKG
rebuilding outPKG3.toc because outPKG3.pkg is missing
building PKG outPKG3.pkg
checking EXE
rebuilding outEXE2.toc because Hey Mang!.exe missing
building EXE from outEXE2.toc
I: SRCPATH [('heymang.ico', None)]
I: Updating icons from ['heymang.ico'] to c:\users\poblet\appdata\local\temp\tmpr34zmp
I: Writing RT_GROUP_ICON 0 resource with 76 bytes
I: Writing RT_ICON 1 resource with 1128 bytes
I: Writing RT_ICON 2 resource with 4264 bytes
I: Writing RT_ICON 3 resource with 9640 bytes
I: Writing RT_ICON 4 resource with 16936 bytes
I: Writing RT_ICON 5 resource with 67624 bytes
它们在文件夹中,但由于某种原因它们不起作用。
整个源代码(减去 PyInstaller 文件)在这里。
我感谢您的帮助。