# Add image on a Python Tkinter button

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

Tkinter, which is the GUI library for python programming has a feature to add images to the GUI buttons. This is useful for users to remember the symbols in the GUI rather than the text in the GUI. In the below Tkinter program we show how we can add an image to a GUI button. The photoimage method from the imageKT module is used. We mention the local path to the image file.

## Example

from tkinter import *
from PIL import ImageTk ,Image

base = Tk()
base.title('Start Button')

img=ImageTk.PhotoImage(Image.open ("D:\button.jpg"))
lab=Label(image=img)
lab.pack()

button=Button(base,text='exit',command=base.quit)
button.pack()
base.mainloop()

## Output

Running the above code gives us the following result −

Updated on 18-Feb-2020 10:23:22

Advertisements