我试图在Python中将背景图像添加到画布。到目前为止,代码如下所示:在python中添加背景图像
from Tkinter import *
from PIL import ImageTk,Image
... other stuffs
root=Tk()
canvasWidth=600
canvasHeight=400
self.canvas=Canvas(root,width=canvasWidth,height=canvasHeight)
backgroundImage=root.PhotoImage("D:\Documents\Background.png")
backgroundLabel=root.Label(parent,image=backgroundImage)
backgroundLabel.place(x=0,y=0,relWidth=1,relHeight=1)
self.canvas.pack()
root.mainloop()
它返回一个AttributeError:光象
谢谢回复! 所以...我如何将图像加载到画布上? – user1689935
请参阅我编辑中的示例 – joaquin
是否仍有可能在图像上绘制其他东西? – user1689935