在Python Tkinter中销毁图像

在Python Tkinter中销毁图像,python,image,tkinter,Python,Image,Tkinter,我的问题是如何通过单击按钮销毁图像 这是图片上传 img1=PhotoImage(file=“C:/Users/Stavr/Desktop/giphy.gif”) w1=标签(根,图像=img1) w1.位置(x=360,y=380) 这是按钮 delete_image_Button=Button(root, text="delete image", command=delete_image_function) 这里是函数 def delete_image_function(): ??

我的问题是如何通过单击按钮销毁图像

这是图片上传

img1=PhotoImage(file=“C:/Users/Stavr/Desktop/giphy.gif”)
w1=标签(根,图像=img1)
w1.位置(x=360,y=380)

这是按钮

delete_image_Button=Button(root, text="delete image", command=delete_image_function)
这里是函数

def delete_image_function():
    ???????????

好吧,我想问题很清楚。有人能帮我填一下这个密码吗?提前谢谢

你可以这样做

from tkinter import *

root=Tk()

img1=PhotoImage(file='firstimage.gif') #the image that is displayed first
img2=PhotoImage(file='secondimage.gif') #the second image that will appear when the first is destroyed

image_1 = Label(root, image=img1)
image_1.place(x = 100, y = 100)

def delete_image():
    image_1.destroy()
    image_2=Label(root,image=img2)
    image_2.place(x=0,y=0)

Button(root,text='Delete_image',command=lambda:delete_image()).place(x=200,y=200)
root.mainloop()

我希望这有帮助。

w1.destroy()
?好的,谢谢。现在我想要一个新的图像在同一个地方你是说你想在删除它的同时替换它吗