Troubles with displaying background on Python. Canvas Troubles with displaying background on Python. Canvas tkinter tkinter

Troubles with displaying background on Python. Canvas


The image should be declared before calling create_image like you did above for mister Vader:

root = Tk()root.title("YeGame")root.minsize(width = WIDTH, height = HEIGHT)root.maxsize(width = WIDTH, height = HEIGHT)canv = Canvas(root,width =WIDTH,height = HEIGHT, bg="green")canv.create_rectangle(0, 0, WIDTH%SPEED-1, HEIGHT, fill = "yellow")canv.create_rectangle(WIDTH-WIDTH%SPEED+1, 0, WIDTH, HEIGHT, fill = "yellow")background = PhotoImage(file="smallnight.gif")m = canv.create_image((100,100), image = background)canv.pack()canv.focus_set()me = mainHero()canv.bind("<KeyPress>", me.move)root.mainloop()