0
我正在嘗試將圖像添加到畫布。 我從以前的論壇答案竊取了代碼,並且它不工作。ImageTk.PhotoImage給出不存在消息
img = Image.open(filename)
self.currentImage['data'] = img
photo = ImageTk.PhotoImage(img)
label = tk.Label(image=photo)
label.image = photo
self.c.xview_moveto(0)
self.c.yview_moveto(0)
self.c.create_image(0, 0, image=photo, anchor='nw', tags='img')
self.c.config(scrollregion=self.c.bbox('all'))
self.currentImage['photo'] = photo
在create_image行產生消息「_tkinter.TclError:image」pyimage1「不存在」。
我讀過很多關於這個問題的答案,但所有這些都是關於做參考,或者使用lift來改變顯示順序。 但是我甚至沒有超越畫布的創作。
我錯過了什麼?
感謝。我會研究一下。 – Garry