I'm building a Windows one file executable of my wxPython app with Pyinstaller. I want to add a window icon and doing pyinstaller --icon=test.ico --onefile --noconsole test.pyw
is perfectly fine only if I put the test.ico file just next to the builded executable. This makes me distribute both the exe and the icon, and that's at least uncomfortable.
I also do
icon = wx.EmptyIcon()
icon.CopyFromBitmap(wx.Bitmap("test.ico", wx.BITMAP_TYPE_ANY))
self.SetIcon(icon)
in my wxPython app.
My research says a suggestion to hardcode a base64 string representation of the icon but it's an insanely long string as I also need to print on paper my code. I saw this other post and I sense it has my answer but I just don't understand it.
So. How can I embed the icon to the exe?
EDIT: .spec
file
# -*- mode: python -*-
block_cipher = None
a = Analysis(['test.pyw'],
pathex=['D:\\test'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='test',
debug=False,
strip=False,
upx=True,
console=False , icon='test.ico')