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()
1from tkinter import *
2
3# Create object
4root = Tk()
5
6# Adjust size
7root.geometry("400x400")
8
9# Add image file
10bg = PhotoImage(file = "Your_img.png")
11
12# Create Canvas
13canvas1 = Canvas( root, width = 400,
14 height = 400)
15
16canvas1.pack(fill = "both", expand = True)
17
18# Display image
19canvas1.create_image( 0, 0, image = bg,
20 anchor = "nw")
21
22# Add Text
23canvas1.create_text( 200, 250, text = "Welcome")
24
25# Create Buttons
26button1 = Button( root, text = "Exit")
27button3 = Button( root, text = "Start")
28button2 = Button( root, text = "Reset")
29
30# Display Buttons
31button1_canvas = canvas1.create_window( 100, 10,
32 anchor = "nw",
33 window = button1)
34
35button2_canvas = canvas1.create_window( 100, 40,
36 anchor = "nw",
37 window = button2)
38
39button3_canvas = canvas1.create_window( 100, 70, anchor = "nw",
40 window = button3)
41
42# Execute tkinter
43root.mainloop()
1from PIL import Image, ImageTk
2import tkinter as tk
3
4IMAGE_PATH = 'sfondo.png'
5WIDTH, HEIGTH = 200, 200
6
7root = tk.Tk()
8root.geometry('{}x{}'.format(WIDTH, HEIGTH))
9
10canvas = tk.Canvas(root, width=WIDTH, height=HEIGTH)
11canvas.pack()
12
13img = ImageTk.PhotoImage(Image.open(IMAGE_PATH).resize((WIDTH, HEIGTH), Image.ANTIALIAS))
14canvas.background = img # Keep a reference in case this code is put in a function.
15bg = canvas.create_image(0, 0, anchor=tk.NW, image=img)
16
17# Put a tkinter widget on the canvas.
18button = tk.Button(root, text="Start")
19button_window = canvas.create_window(10, 10, anchor=tk.NW, window=button)
20
21root.mainloop()