我想设置一个PNG作为背景图像在一个保管人的用户界面我有这个代码
import customtkinter
import random
from PIL import Image
import PIL
customtkinter.set_appearance_mode("light")
# Create a list to track the names that have already been chosen
chosen_names = []
def button_callback():
# Create a list of names
names = ["Alice", "Bob", "Carol", "Dave", "Eve"]
# Randomly select a name from the list
name = random.choice(names)
# Check if the name has already been chosen
while name in chosen_names:
name = random.choice(names)
# Add the name to the list of chosen names
chosen_names.append(name)
# Get the label
#label = app.winfo_children()[0]
# Update the label text
label.configure(text=name)
label.grid_remove()
# Check if all the values in the list have been selected
if len(chosen_names) == len(names):
chosen_names.clear()
label.configure(text="")
app = customtkinter.CTk()
image = PIL.Image.open("Imagen.png")
background_image = customtkinter.CTkImage(image)
app.title("app")
app.iconbitmap('isologo.ico')
app.geometry("500x500")
# Create a label
label = customtkinter.CTkLabel(app)
label.pack(padx=0, pady=0)
label.configure(text="")
button = customtkinter.CTkButton(app, text="Selector Nombre", command=button_callback)
button.pack(ipadx=20, ipady=20,padx=20, pady=50)
app.mainloop()
我该如何设置
image = PIL.Image.open("Imagen.png")
个
作为背景?背景可以是静态的,不需要改变大小,但如果react 灵敏一点,就会好得多.