# - * - coding: GBK - * -
The import tkinter as tk
The from tkinter import messagebox
Windows=tk. Tk ()
# window name
Windows. Title (' Windows')
# set the window size
Windows. Geometry (' 600 x500 ')
# set the picture
# set the canvas size
Canvas_mainbg=tk Canvas (Windows, height=250, width=600)
# set photo file path
Mainbg_file=tk. PhotoImage (file=r 'C: \ PycharmProjects \ untitled \ picture background material \ _1. The GIF')
# set a variable in the position of the canvas, then add photos to variable
Mainbg=canvas_mainbg. Create_image (0, 0, anchor=' 'nw, image=mainbg_file)
# set the canvas position
='top' canvas_mainbg. Pack (side)
Windows. Mainloop ()
Don't set the photo size
Want photos to fill the canvas