在 CustomTkinter 中模糊按钮

问题描述 投票:0回答:1

我正在制作一个 GUI,并且正在使用 customtkinter。我想知道如何使按钮变得模糊,如下所示: enter image description here

python user-interface tkinter
1个回答
0
投票

我已经通过使用 Pillow Library 成功做到了这一点。代码解释: 首先我创建按钮:

self.WarmUp = WarmUpButton(self.MenuLeft)
self.WarmUp.place(relx=0.15, rely=0.2)

然后我创建一个标签,在其中放置图像,代码如下:

class WarmUpBlur(ctk.CTkLabel):
    def __init__(self, parent):
        super().__init__(parent)
        self.configure(image=ctk.CTkImage(light_image=Image.open('Images/image-6.webp'),
                                          dark_image=Image.open('Images/image-6.webp'),
                                          size=(200, 40)))
        self.configure(text='')

图像是用 place 方法放置的,然后当按下按钮时,我使用button.place_forget()方法删除图片。

© www.soinside.com 2019 - 2024. All rights reserved.