Image buttons with Tkinter

Hans Nowak hnowak at
Mon Nov 8 17:36:10 EST 1999

On 8 Nov 99, at 10:17, Thomas Lane wrote:

> I'm trying to create a button that displays an image instead of text, but
> I don't seem to be having any luck. The button just comes up gray. Here is
> a code snippet of what I'm trying to do:
>   # Put remove.gif on a button (actionbar is a frame for various
> controls)
>   deletebutton = Button(actionbar,image=PhotoImage(file="remove.gif"))

This code worked for me (I threw in a label so the button will be 
clearly visible rather than taking up the whole frame):


from Tkinter import *

root = Tk()

image1 = PhotoImage(file='burger.gif')

button = Button(root, image=image1)

Label(root, text="Bwahahaha").pack()



> What am I doing wrong here?

Dunno, it looked good to me, although I never use the 'place' thingy.

> Also, is there a place on the net where I can find lots of sample
> Python/Tkinter code? I've read Fredrik Lundh's intro, but I haven't been
> able to find any other code or reference material for Tkinter.

As far as I know, the Tk introduction is about the best you can get 
at the moment. <waiting for Tk books...>

--Hans Nowak (zephyrfalcon at
You call me a masterless man. You are wrong. I am my own master.

More information about the Python-list mailing list