Skip to content

Python code snippet – How to set background image in tkinter frame?

om tkinter import *
from PIL import ImageTk

canvas = Canvas(width=600, height=800, bg='blue')
canvas.pack(expand=YES, fill=BOTH)

image = ImageTk.PhotoImage(file="File route")
canvas.create_image(10, 10, image=image, anchor=NW)

mainloop()
See also  How to remove the body margin from navbar in CSS?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.