Changing the Image on a button

odeits odeits at
Mon Feb 16 02:18:50 EST 2009

I want to be able to toggle if the button has an image or text. For
some reason the following code gets the button to have an image but
when i push the button i expect the image to go away but it does not.
Am I missing something?

from Tkinter import *

def do():
    btn.configure(image = None)

root = Tk()
img1 = PhotoImage(file="bacon.gif")

btn = Button(image = img1, command = do, text = "hello" )
btn.img = img1

More information about the Python-list mailing list