Adding an Image to a Form in Python - The Advantages of Learning Python Programming for Beginners: A Comprehensive Guide

Latest

Dive into the world of Python programming with our comprehensive resources

Music

logo

Thursday, March 9, 2023

Adding an Image to a Form in Python

 

In this article, I will add an image to the form in python.

I will use the canvas method for this.

 


 

 

 

 

 

 

 

 

Figure 1

 

 

from tkinter import *

 

canvas_width = 200

canvas_height =200

 

root = Tk()

root.title("canvas image..bs")

 

canvas = Canvas(root,

           width=canvas_width,

           height=canvas_height)

canvas.pack()

 

img = PhotoImage(file="D:\\matrix.gif")

canvas.create_image(100,100, anchor='center', image=img)

 

root.mainloop()


Happy coding.

No comments:

Post a Comment

Featured post

Python Introduction

What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built ...