import customtkinter as ctk
from tkinter import *
from PIL import Image, ImageTk
def resize_image(event=None):
width, height = window.winfo_width(), window.winfo_height()
resized_image = image.resize((width, height))
photo = ImageTk.PhotoImage(resized_image)
background.configure(image=photo)
background.image = photo
window = ctk.CTk()
width = 1280
height = 720
window.geometry(f"{width}x{height}")
window.resizable(False, False)
window.wm_attributes('-transparentcolor', '#ab23ff')
image = Image.open("testImages/istockphoto-1185382671-612x612.jpg")
photo = ImageTk.PhotoImage(image)
background = ctk.CTkLabel(window, image=photo, text="")
background.configure(image=photo)
background.bind("<Configure>", resize_image)
background.place(x=0, y=0)
#frame = ctk.CTkFrame(window, width=1250, height=690, bg_color="gray")
#frame.place(x=15, y=15)
btn = ctk.CTkButton(window, text="Start", width=150, corner_radius=10, border_width=0, bg_color="#000000")
btn.place(x=460, y=360)`
我尝试查看文档,但我发现似乎没有任何效果,并且文档中没有关于透明度的具体内容。
如果您需要更多帮助,可以使用“pywinstyles”方法。它使某种颜色不可见,之后您可以在按钮中使用它。
`import pywinstyles
btn = ctk.CTkButton(window, text="Start", width=150, corner_radius=10,
border_width=0, bg_color="#000001") #Your color that becomes invisible
btn.place(x=460, y=360)
pywinstyles.set_opacity(button, color="#000001") #You specify the color that
will be invisible`