***Error message :
Traceback (most recent call last):
File "C:/Users/gurse/Desktop/Khanda/Khanda.py", line 3, in <module>
label = Label(x, image=PhotoImage(file=r"C:\Users\gurse\Desktop\Khanda"))
File "C:\Users\gurse\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 4062, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Users\gurse\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 4007, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "C:\Users\gurse\Desktop\Khanda": permission denied *****
My current code :
from tkinter import *
x = Tk()
label = Label(x, image=PhotoImage(file=r"C:\Users\gurse\Desktop\Khanda"))
And the backslashes turn into a Y with 2 lines across it.
That error says that it can't reach the image.
In this case, you have put only the path of the image, but the image name isn't included in it.
To resolve, you have to put also the name of the image in the path like:
A small advice -> PhotoImage takes only a few extensions for images (ie. jpeg will occur an error)
I hope that I've been clear ;)
EDIT: The user acw1668 isn't wrong: you have to use the method
mainloop()
to show the window with the widgets