
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add Image on a Python Tkinter Button
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 −
Advertisements