Search code examples
pythonuser-interfacetkinter

Blurring a button in CustomTkinter


I am making a GUI and I am using customtkinter. I am wondering, how can I make a button blurred, like this: enter image description here


Solution

  • I've managed to do it by using the Pillow Library. Explanation of the code: First I create the button:

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

    then I create a label in which I place the image with the following code:

    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='')
    

    The image is placed with the place method and then when the button is pressed i am using button.place_forget() method to remove the picture.