I have got my file working on my program. However, I am not sure how to load an image from a file that is in a specific folder. So far is my following code, which only can obtain the image directly in the same folder as the program file itself.
from tkinter import *
root = Tk()
canvas = Canvas(root, width=500, height=500)
canvas.pack()
imagetest = PhotoImage(file="giftest.gif")
canvas.create_image(250, 250, image=imagetest)
root.mainloop()
I had found some info on this YouTube video about how to link the file to a specific folder, but it only tells the whole destination. I cannot guarantee that the whole folder destination stuff shown by that video will always work if I move the folder containing the program to a different destination; moving that folder will break the image links in the program.
Is there some way of loading an image from a folder that is in the same folder as the program is? I recall that HTML could do this kind of thing too, but I don't know whether Python could do this either.
https://stackoverflow.com/questions/47357090/tkinter-error-couldnt-recognize-data-in-image-file/68805933#68805933 – team meryb Aug 16 '21 at 16:07