Python Tkinter remove/delete Image from Label Python Tkinter remove/delete Image from Label tkinter tkinter

Python Tkinter remove/delete Image from Label


You're very close - the image parameter just needs an empty string rather than None.

def clear_label_image():    brand_preview.config(image='')


After some Googling, I found this solution

def clear_label_image():    #brand_preview.config(image = None)    brand_preview.image.blank()    brand_preview.image = None

This definitely clears the image from the button. I haven't tried changing to a new image.

I just copied it from the Web, and it worked. I created the image with

photoimg_brand = tk.PhotoImage(file='/usr/share/httpd/icons/world1.gif')

I did this with python 2.7, and my only import was import Tkinter as tk


If you are using label to show the image then you can do this:

label.pack_forget()

label should be global