我希望从URL加载列表单击事件上的图像,然后在Tkinter标签中显示它们。当我加载它们时,它们显示为裁剪。有人能告诉我为什么吗?
def OnSelect(evt):
w = evt.widget
index = int(w.curselection()[0])
print("URL : " + URLs[index])
response = requests.get(URLs[index])
img_data = response.content
image = Image.open(BytesIO(img_data))
img = ImageTk.PhotoImage(image)
panelImage.configure(image=img, width=50, height=10)
panelImage.image = img
panelImage = Tkinter.Label(window, text="", width=50, height=10, borderwidth=4, relief="ridge")
panelImage.grid(column=2, row=1)
谢谢
正如Byan Oakley非常正确地说...
panelImage.configure(image=img)
和
panelImage = Tkinter.Label(window, text="", borderwidth=4, relief="ridge")