我試圖在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