如何停止用Python裁剪Tkinter PhotoImage

问题描述 投票:0回答:1

我希望从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)

谢谢

python tkinter label crop photoimage
1个回答
0
投票

正如Byan Oakley非常正确地说...

panelImage.configure(image=img)

panelImage = Tkinter.Label(window, text="", borderwidth=4, relief="ridge")
© www.soinside.com 2019 - 2024. All rights reserved.