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)