Python将背景图像调整为全屏

问题描述

我最近开始了一个网站项目,但找不到任何方法来调整我的登录背景图片的大小。

有人可以帮我吗?

这是我目前的代码

root = Tk()  
root.overrideredirect(True)
root.overrideredirect(False)
root.attributes('-fullscreen',True)  
root.title('Login|Registration')
bg = PhotoImage(file = Login.png')


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

copy_of_bg = bg.copy()
photo = ImageTk.PhotoImage(bg)
label = ttk.Label(root,bg = photo)
label.bind('<Configure>',resize_bg)
label.pack(fill=BOTH,expand = YES)

root.mainloop()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)