image files packaged into single file executalble py pyinstaller
"Brendan Simon (eTRIX)" <[email protected]>
| Newsgroups | gmane.comp.python.wxglade |
|---|---|
| Organization | eTRIX pty ltd |
| Message-ID | <[email protected]> |
I want to build my wxpython app as a Mac app bundle, using pyinstaller.
I can get it to run ok on my PC, because the images that were created
via wxglade actually exist on my Mac. i.e. the hardcoded absolute paths
that wxglade generates will only work on my Mac.
One possible solution is to insert relative paths. e.g
`images/logo.png` instead of `/Users/brendan/project/src/images/logo.png`
However that wont work when using the `--onefile` option (to build a
single file executable). This option compresses the specified
data/image files into the binary, and uncompresses them to a temporary
directory (with randomish name).
Pyinstaller recommend specifying the path to the data/image file with:
|image_path =resource_path("myimage.png")|
using:
|defresource_path(relative_path):""" Get absolute path to resource,
works for dev and for PyInstaller """base_path
=getattr(sys,'_MEIPASS',os.path.dirname(os.path.abspath(__file__)))returnos.path.join(base_path,relative_path)|
`image_path` will resolve to either a local working directory (if
running directly, when in development) or to the temp directoy in the
app bundle (when run from the onefile app bundle)
*How can wxglade be used to design a GUI with an image, and satisfy
pyinstaller (without having to edit the wxglade generated files !!)*
My only thought is some kind of automatic post processing, after wxglage
has generated the files, to ratchet in the appropriate code. Are there
hooks in wxglade for this?
https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile
http://pyinstaller.readthedocs.io/en/stable/usage.html#options-group-what-to-bundle-where-to-search
Thanks,
Brendan.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
wxGlade-general mailing list
wxGlade-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/wxglade-general