I have created an app in which i am using png images as buttons. I included those images in the exe files as data when i was creating the exe file through pyinstaller, but those images are not shown in the exe file. I manually copied and pasted those images in the folder where the exe file is but still those images are not shown. what could go wrong any idea ? please
Related
Please I need to create a distributable EXE file as only ONE file from Python 3.7 code, that includes integrated a PNG image as a background and ICO image as an Icon using pyinstaller. So far, all the EXE files that I have created need the PNG and ICO files in order to be distributed and run, losing the main goal of the EXE as only ONE file distributed.
I did the setting of full path for files PNG and ICO in the code but the EXE only run in my pc and the files must be located in the specified path.
Even using AUTO-PY-TO-EXE the result is the same.
I need that EXE file has integrated the PNG and ICON files.
Please any suggestion and/or reference to any similar post solved.
For any test just use any PNG and ICO file including full path location.
from tkinter import *
root=Tk()
#set windows size
root.resizable(width=False, height=False)
root.geometry("925x722")
#set title
root.title("SOFT1)")
#frame 1
f1=Frame(root, width=345,height=475,bg="light
grey",highlightbackground="black",highlightthickness=4)
f1.place(x=20,y=235)
#set a image as BG
Logo=PhotoImage(file="PNG_File.png")
lab6=Label(root, image=Logo)
lab6.place(x=0, y=0)
#set a image as ICON
root.iconbitmap("ICO_File.ico")
mainloop()
I hope until now you found your solution, but I saw in another post that explained the same concept. I copied this function below and when i needed to create the image files in my app i used this function and inside the file name:
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
I tried afterward to run my .py file with auto-py-to-exe and that solved the problem for me.
From a brief look at what you're doing, you can't do that. Have you considered distributing your program as a .zip instead?
You can't do what you're trying to do because that load function is taking a file path - specifically a file path to the directory the script is run in, and searching for images in that directory. Without the images being there, it will fail on loading them. It's that simple.
Is there a way to save the Python pptx file on Google drive or desktop?
I tried Prs.save() to save the pptx file, but it doesn't work.
Your presentation will be saving to the Files panel on the left of Colab:
From here you can download the saved presentation file.
If you want to save to Google Drive you need to mount the drive (icon is at the top of the Files panel) and then simply append the relevant path to your file name when saving:
prs.save("/content/drive/My Drive/.../presentation.pptx")
I want to be able to show the GUI user the code used to do background calculations. However copying and pasting and using "\n" in a text box takes forever. Now I know you can save the code as a pdf. Is there a simple way to attach the pdf to the program and the code still be readable even when it is moved to a different computer.
Main issues:
- How to import and attach a pdf to a button...
- How to include pdf into program so it is readable on any pc...
Thanks in advance.
Packaging:
You can attach your code as pdf file with your program like this using pyinstaller
On Windows:
pyinstaller --add-data="relative/full_path_to_pdf;." my_script.py
On Linux:
pyinstaller --add-data="relative/full_path_to_pdf:." my_script.py
This will pack your pdf file and copy it to the same folder as the .exe package(in case of single file, it will extract it to the temp path along with main .exe which can be accessed with sys._MEIPASS) or You can change the extraction path instead of using '.' Read more here.
In Code:
You can add this type of button in your UI, to open the pdf file with the default viewer of Windows/Linux(same behavior as when you double click the file)
source_code_btn = Button(root, text="Source", command=lambda: subprocess.Popen('{} {}'.format(
"start" if os.name=="nt" else "xdg-open \"$#\" 2>/dev/null",
relative/full_path_to_pdf_file), shell=True))
I am trying to edit some game files using Notepad ++ but the contents aren't showing up. The file extension is .pas, any ideas? Here is an image of the file.
Why the file uva_icona isn't recognized as png file when I paste it in the res\drawable folder?
Perhaps I found the issue. I must paste png file in drawable directory but when it shows windows with destination folder I must erase .png extension from the file name as shown in the picture. Then files are properly paste and they shows correct image icon