Hello, Can someone help me in Fixing the code below? I need to put image which is school.jpg as a background image in my Python GUI using Tkinter but apparently, it didn't appear. Only grey color was present in there. Thanks.
from tkinter import * from PIL import ImageTk, Image class Student: def __init__(self, root): # no resize for both directions height = 750 width = 1230 x = (root.winfo_screenwidth() // 2) - (width // 2) y = (root.winfo_screenheight() // 2) - (width // 2) self.root = root self.root.title("Image") self.root.geometry('{}x{}+{}+5'.format(width, height, x, y)) self.root.config(bg="forestgreen") StdID = StringVar() Firstname = StringVar() Surname = StringVar() DoB = StringVar() Age = StringVar() Gender = StringVar() Address = StringVar() Mobile = StringVar() # Frame img = Image.open('images\\school.jpg') bg = ImageTk.PhotoImage(img) MainFrame = Label(self.root, image = bg) MainFrame.place(x=0, y=0) MainFrame.grid() if __name__ == '__main__': root = Tk() application = Student(root) root.mainloop()