1om tkinter import *
2from PIL import ImageTk
3
4canvas = Canvas(width=600, height=800, bg='blue')
5canvas.pack(expand=YES, fill=BOTH)
6
7image = ImageTk.PhotoImage(file="File route")
8canvas.create_image(10, 10, image=image, anchor=NW)
9
10mainloop()
11
1app = Tk()
2app.title("Welcome")
3image2 =Image.open('C:\\Users\\adminp\\Desktop\\titlepage\\front.gif')
4image1 = ImageTk.PhotoImage(image2)
5w = image1.width()
6h = image1.height()
7app.geometry('%dx%d+0+0' % (w,h))
8#app.configure(background='C:\\Usfront.png')
9#app.configure(background = image1)
10
11labelText = StringVar()
12labelText.set("Welcome !!!!")
13#labelText.fontsize('10')
14
15label1 = Label(app, image=image1, textvariable=labelText,
16 font=("Times New Roman", 24),
17 justify=CENTER, height=4, fg="blue")
18label1.pack()
19
20app.mainloop()
1You need to apply the grid method to the label that contains the image, not the image object:
2
3bg_image = PhotoImage(file ="pic.gif")
4x = Label (image = bg_image)
5x.grid(row = 0, column = 0)
6http://effbot.org/tkinterbook/photoimage.htm