Python in one Exe file with Images INCLUDED
The solution to this is a little tricky, but if you follow this video you will get it finally. I tried different solutions and put it into practise... so let's see how to make one exe file containing our code for a python app, including the images into the exe file... cool! The post for this topic: https://pythonprogramming.altervista.org/auto-py-to-exe-only-one-file-with-images-for-our-python-apps/ My Blog with a loto of example with python, tkinter, pygame, sublime text etc. https://pythonprogramming.altervista.org/ My github repositories https://github.com/formazione Remember to call your images with the function resource_path # =============== copy this code ========================= def resource_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__))) return os.path.join(base_path, relative_path) # ================================= Example of use of the function in an app to make the images included into the exe (in this case an image to be used into a tkinter GUI) # ===== example of usage of the function to make loading resources work in pyinstaller ==== img = tk.PhotoImage(file=resource_path(filename[0])) # ====================
Download
0 formatsNo download links available.