
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
Display Image Using Pillow in Tkinter
Python provides Pillow Package (PIL) to process and load the images in the application. An image can be loaded using the inbuilt Image.open("image location") method. Further, we can use a Label widget to display the Image in the window.
Example
#Import tkinter library from tkinter import * from PIL import Image,ImageTk #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("750x550") #Load the image img= Image.open("tutorialspoint.jpg") #Convert To photoimage tkimage= ImageTk.PhotoImage(img) #Display the Image label=Label(win,image=tkimage) label.pack() win.mainloop()
Output
Running the above code will display an image in the window.
Before executing the code, make sure you have the image in the same project directory, or provide the absolute path of the image location.
Advertisements