hi.... i'm trying to write a function clear image but i am not being able to write it.
it is as follows. i am loading a picture and i want by clicking the button clear, the picture map.gif dis appear..

there is a function blank in tkinter but i am not being able to use it well to perform this.
can anyone tell me how to do it?????

thanx

import Tkinter
from Tkconstants import *

def window(tk):
    global photo       
    frame=Tkinter.Frame(tk)
    frame.pack()
    
    canvas=Tkinter.Canvas(frame,bg ='white', width=500,height=500)
    canvas.pack()
    
    
    obj1 = canvas.create_text(250, 10, text='Simulation ',font=('verdana', 16, 'bold'))
   
    
    
    
    button=Tkinter.Button(frame, fg ="blue",text="Clear",activebackground='red',command=clear).pack(side =LEFT, padx=20)
    photo=Tkinter.PhotoImage(file="map.gif")
    canvas.create_image(200, 250, image=photo)


def clear():
# can anyone tell me how to write the function clear image
    
    

    

      

    
root = Tkinter.Tk()
root.title("Simulation")
window(root)
root.mainloop()

If you want to clear the whole canvas instance of all items on it, use:
canvas.delete('all')

commented: you are getting good with Python +7

i don't want to delete the whole things. i just want the image to be deleted...
can you tell be how i can do it????

Then you have to give your image object a name ...
img1 = canvas.create_image(200, 250, image=photo)
... and delete that on specifically...
canvas.delete(img1)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.