Tkinter:创建模糊透明度

Tkinter : Create blur transparency

我想知道如何在 tkinter 中创建模糊透明效果。我已经知道如何使用

将透明效果添加到 window
root=Tk()
root.attributes("-alpha",0.95)

但是如何添加模糊部分呢?

tkinter 不提供此服务。但是你可以 take a screenshot of your app and blur it yourself (see for instance ImageFilter.GaussianBlur or numpy.gaussian filter).

您应该使用 "BlurWindow" 包并以这种方式安装它:

python -m pip install BlurWindow

from tkinter import *
from ctypes import windll

from BlurWindow.blurWindow import blur

root = Tk()
root.config(bg='green')

root.wm_attributes("-transparent", 'green')
root.geometry('500x400')

root.update()

hWnd = windll.user32.GetForegroundWindow()
blur(hWnd)



def color(hex):
    hWnd = windll.user32.GetForegroundWindow()
    blur(hWnd,hexColor=hex)
    

e = Entry(width=9)
e.insert(0,'#12121240')

e.pack()
b = Button(text='Apply',command=lambda:[color(e.get())])
b.pack()


root.mainloop()