

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to insert an image in a Tkinter canvas item?
Tkinter canvas is the most versatile widget in the Tkinter library. It is used to create images, shapes, arcs, animating objects, and many more other works. In order to work and process the images, Python supports Pillow Package or PIL. We can add images in the canvas as the items using the create_image(width, height, image_location, options) method. We can also specify where the image should open in the window by defining the Positional arguments such as anchor(options) property.
Example
#Import the required Libraries from tkinter import * from PIL import Image,ImageTk #Create an instance of tkinter frame win = Tk() #Set the geometry of tkinter frame win.geometry("750x250") #Create a canvas canvas= Canvas(win, width= 600, height= 400) canvas.pack() #Load an image in the script img= ImageTk.PhotoImage(Image.open("download.png")) #Add image to the Canvas Items canvas.create_image(10,10,anchor=NW,image=img) win.mainloop()
Output
Run the above code to display the image in the canvas.
- Related Questions & Answers
- How to update an image in a Tkinter Canvas?
- How to center an image in canvas Python Tkinter
- How to Move an Image in Tkinter canvas with Arrow Keys?
- Embedding an Image in a Tkinter Canvas widget using PIL
- How to open PIL Image in Tkinter on Canvas?
- How to draw a png image on a Python tkinter canvas?
- How to set the font size of a Tkinter Canvas text item?
- How to draw an arc on a tkinter canvas?
- How to insert an item in ArrayList in C#?
- How do I find out the size of a canvas item in Tkinter?
- How to add an image in Tkinter?
- How to Insert an Image in HTML Page?
- Tkinter - How to put an outline on a canvas text
- How to resize an image using Tkinter?
- How do I insert a JPEG image into a Python Tkinter window?
Advertisements