I'm trying to have an image in a window in tkinter in a class but i cant get it to work, without the image lines it shows an empty window but when I execute the code with the lines for the image, I get an error saying: 'Img_window' object has no attribute 'tk'.
How can I change the code to show the image?
Here is the code:
from tkinter import *
from PIL import Image, ImageTk
class Img_window:
def __init__(self):
self.window = Tk()
self.window.title("Image")
image_open = Image.open("welcome.jpg")
welcome_img = ImageTk.PhotoImage(image_open)
image_label = Label(self, image = welcome_img)
image_label.grid(row=1,columnspan=3)
self.window.mainloop()
img_window = Img_window()