我在做一个视频游戏,但我遇到一个问题:我在函数中使用canvas.create_image(),但是看不到任何图像...
我试图在函数外使用create.image(),但是它可以正常工作,但是我需要在函数中使用create.image()...
这是我的代码:
from tkinter import *
def move_down(evt):
# move
global x, y
y += 40
# insert the image in the canvas
image = PhotoImage(file="Perso_down.png")
the_sea.create_image(x, y, image=image)
fenetre = Tk()
fenetre.title('Raft')
fenetre.attributes("-fullscreen", 1)
# creation of the sea
the_sea = Canvas(fenetre, width=1920, height=1080, bg='dark blue')
the_sea.pack()
# player coordinates
x, y = 950, 540
# events
fenetre.bind('s', move_down)
fenetre.mainloop()```
I dont have any error...
Thanks for help