I am building an executable using PyInstaller (v1.5) -- also, I am using GUI2EXE to assist me. My script calls for an icon file located in the working directory:
icon_file = '\pics\myicon.ico'
When I build the executable, i would like to not have to include the "working directory", rather have the icon file included right in my executable. Is there a way to do this?
If this doesn't make since, I want one file (my executable) that includes my icon file.
- How do I create one file to include the icon files?
- How do I update my script code to access that icon file correctly?
I'm also looking to do this for any image file or even data file...
Thanks!
So rather than the actual icon of the distributed executable, you're looking at including an icon or other image that your python script will open/read from disk at runtime?
Additional data can be bundled in your exe, and pyinstaller provides a method of accessing it at runtime. This question shows how to include it in your .spec, and the answer shows how to access it via your script:
Bundling data files with PyInstaller (--onefile)
I'm not very familiar with GUI2EXE, but you can specify an icon file (scroll down a bit for the Windows/OS X specific options) on the command line while you're building the spec file. That'll set it as the application's icon and you won't have to distribute the icon separately. Looking at the spec file it generates, it adds an icon argument in the exe like so:
exe = EXE(pyz,
a.scripts,
[bunch of other arguments],
icon='\pics\myicon.ico')