यदि हम Tkinter frame का instance बनाएंगे और window display करेंगे जबकि इसे चलाते रहेंगे, तो यह default output canvas दिखाएगा। हालांकि, हम PhotoImage methods और Canvas methods का उपयोग करके Tkinter canvas के अंदर एक image को background के रूप में जोड़ सकते हैं।
चूंकि Tkinter में image support GIF, PNG और PPM तक सीमित है, PhotoImage(GIF, PNG, PPM) फंक्शन image file का location लेता है और image को background के रूप में canvas display करता है।
पहले, हम PhotoImage function का उपयोग करके एक PhotoImage Object बनाएंगे।
उदाहरण
from tkinter import *
from PIL import ImageTk
win = Tk()
win.geometry("700x300")
# Define the PhotoImage Constructor by passing the image file
img = PhotoImage(file='down.png', master=win)
img_label = Label(win, image=img)
# Define the position of the image
img_label.place(x=0, y=0)
win.mainloop()
आउटपुट
उपरोक्त code snippet चलाने से background image के साथ एक window display होगी।
