Changing the Image on a button

odeits odeits at gmail.com
Mon Feb 16 22:04:38 EST 2009


On Feb 16, 8:40 am, John Posner <jjpos... at snet.net> wrote:
>  >> 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
>  >> btn.pack()
>  >> root.mainloop()
>  >>
>
> Try this change:
>
>   from: btn.configure(image = None)
>     to: img1.blank()
>
> -John
>
> E-mail message checked by Spyware Doctor (6.0.0.386)
> Database version: 5.11770http://www.pctools.com/en/spyware-doctor-antivirus/

This does in fact clear the image out, however it isn't causing the
text to display... Do i have have to create a new button and swap it
out?



More information about the Python-list mailing list