Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使我使用的图像既可以是背景图像,又可以拉伸以适合我制作的窗口_Python_Tkinter - Fatal编程技术网

Python 如何使我使用的图像既可以是背景图像,又可以拉伸以适合我制作的窗口

Python 如何使我使用的图像既可以是背景图像,又可以拉伸以适合我制作的窗口,python,tkinter,Python,Tkinter,下面是我目前在后台使用的代码 def resize_image(event): new_width = event.width new_height = event.height image = copy_of_image.resize((new_width, new_height)) photo = ImageTk.PhotoImage(image) label.config(image = photo) label.image = photo

下面是我目前在后台使用的代码

def resize_image(event):
    new_width = event.width
    new_height = event.height
    image = copy_of_image.resize((new_width, new_height))
    photo = ImageTk.PhotoImage(image)
    label.config(image = photo)
    label.image = photo #avoid garbage collection

image = Image.open('tlr.png')
copy_of_image = image.copy()
photo = ImageTk.PhotoImage(image)
label = ttk.Label(root, image = photo)
label.bind('<Configure>', resize_image)
label.pack(fill=BOTH, expand = YES)
但我不了解syantax,我也不知道在哪里可以找到它,让它成为编码新手

感谢您的阅读并提前感谢您的帮助

从中选择一个用于图像处理的,请参阅。有关
tkinter
,请参阅。
background_image=tk.PhotoImage(...)
background_label = tk.Label(parent, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)