What I am trying to do:
I am trying to insert an image in a Tkinter Window. For that, I checked both these threads:
How to add an image in Tkinter?
https://pythonprogramming.net/tkinter-adding-text-images/
After checking that, I tried implementing the ideas in my code.
A snippet of the code:
def Alimentacao():
lb11=Label(janela, text="O seu consumo de alimentos:", font = ("Verdana", "16"))
lb11.place(x = 60, y = 255)
load = Image.open("Code.png")
render = ImageTk.PhotoImage(load)
img=Label(janela, image = render)
img.place(x = 400, y = 400)
The error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Joao Zoioi\Anaconda3\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
File "<ipython-input-1-e4cd6e9966ba>", line 98, in Ocupacao
Alimentacao()
File "<ipython-input-1-e4cd6e9966ba>", line 103, in Alimentacao
load = Image.open("Code.png")
File "C:\Users\Joao Zoioi\Anaconda3\lib\site-packages\PIL\Image.py", line 2580, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'Code.png'
What I think the issue is:
Apparently I can't just use the file's name, so I obviously need to have the file path somewhere, I just don't know where that is.
EDIT:
Before asking the question I did my research, as you can see. I went through this post as well:
Python can't open file "No such file or directory"
My question has been suggested to be a duplicate of this post. I disagree, as this other topic is very specific and hardly answers my concern.