如何在Python的Tkinter中使用.create_图像

如何在Python的Tkinter中使用.create_图像,python,tkinter,canvas,Python,Tkinter,Canvas,我想做一个简单的游戏,点击按钮,屏幕上就会显示饮料的图像, 如何使用.create_图像在我喜欢的位置显示图像? 我知道relx/RELN确实不起作用,那么什么是最好的解决方案呢 画布中传递的参数究竟是什么。create_image() 您只需阅读文档即可,无论如何,要创建图像,您可以使用: img=PhotoImage(file='image.png')#透明图像 canvas.create_image(x,y,image=img,anchor='ne') 这将基于-anchor选项在(x,

我想做一个简单的游戏,点击按钮,屏幕上就会显示饮料的图像, 如何使用.create_图像在我喜欢的位置显示图像? 我知道relx/
RELN
确实不起作用,那么什么是最好的解决方案呢

画布中传递的参数究竟是什么。create_image()


您只需阅读文档即可,无论如何,要创建图像,您可以使用:

img=PhotoImage(file='image.png')#透明图像
canvas.create_image(x,y,image=img,anchor='ne')
这将基于-anchor选项在(x,y)坐标处创建图像。还有更多选项,如-state、-tags、-disabledimage。通读一遍。这是我在这里能找到的唯一问题。还注意到您没有将任何坐标传递到:

canvas.create_image(anchor='n', image=bg)

看见顺便说一句,为什么不使用label呢?我的图像是透明的,但是label方法会为图像添加默认的白色背景
canvas.create_image(anchor='n', image=bg)