I have opened an image using the PhotoImage method of ImageTk
How do I close the image.

This is the scenario is I am using it in. I have 2 buttons, one each to open an image from disk & image from url. When I open either of them the image is displayed. But when I open a new image, the old image remains on the screen & the new image is displayed below it.

How do I close the old image so that only the new image is seen.

Code snippet of for opening the images:

def file_open(self):
                filename =askopenfilename(filetypes=imageTypes)
                image1 = ImageTk.PhotoImage(Image.open(filename))
                panel1 = Label(self, image=image1)
                panel1.pack(side='top', fill='both', expand='yes')
                panel1.image = image1
                
        def openurl(self):
                
                url= tkSimpleDialog.askstring("Open URL","Enter URL")
                file =urllib.urlopen(url)
                im = cStringIO.StringIO(file.read()) 
                img = Image.open(im)
                image1 = ImageTk.PhotoImage(img)
                panel1 = Label(self, image=image1)
                panel1.pack(side='top', fill='both', expand='yes')
                panel1.image = image1

vegaseat,
thank you! I used the canvas & I'm able to get what I wanted.
Your quick answers have been a gr8 help for newbies like me.

This question has already been answered. Start a new discussion instead.