要设置Tkinter窗口的背景,请使用以下代码:

from tkinter import *

root = Tk()

# 设置窗口背景颜色
root.configure(background='white')

# 或者设置窗口背景图片
# photo = PhotoImage(file="background.png")
# label = Label(root, image=photo)
# label.pack()

root.mainloop()

其中,使用root.configure(background='white')设置窗口背景颜色为白色,也可以使用一张图片作为背景,通过PhotoImage载入图片文件,然后将其添加到窗口中。

tkinter设置窗口背景

原文地址: https://www.cveoy.top/t/topic/gKfK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录