Add Image in TKinter Canvas

In this TKinter tutorial we are going to learn how to Add Image in TKinter Canvas, as you know the Canvas is a rectangular area intended for drawing pictures or other complex layouts. You can place graphics, text,widgets or frames on a Canvas. We Can Create Difference like arc, polygon, image, line.​ and we have already learned that how you can create arc in the canvas, now we want to add an image in the canvas. 

 

 

For this lesson you need to install Pillow library, so Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. 

 

 

 

This is the complete code for this lesson.

 

 

 

So you can see at the top we have imported these two classes from PIL library.

 

 

You can use tk.Canvas() for creating of the canvas,  you need to give some parameters like background color, height and weight of the canvas.

 

 

First we are going to open the image, make sure that you have already added an image in your working directory, after that we can use create_image() from the canvas for creating the image.

 

 

 

 

Run the complete code and this is the result.

Add Image in TKinter Canvas
Add Image in TKinter Canvas
Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.