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.
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()
Running the above code gives us the following result −