使根窗口透明,并使其他内容可访问



我想将根窗口设置为透明,我很容易做到这一点,但我无法在系统后台移动任何内容,例如我的终端或其他任何东西。

from tkinter import Tk
self.tk = Tk()
self.tk.attributes('-zoomed', True)  # This just maximizes the window
self.tk.wait_visibility() # just to fix self.tk.attributes
self.tk.attributes('-type', 'dock') # disable title and title buttons
self.tk.attributes('-alpha', 0.1) # transparent
self.tk.mainloop() # main loop

我想这样做的原因是因为我想制作一个屏幕截图应用程序,并且我想制作一些使系统透明的效果

您可以在窗口中使任何颜色完全透明。

from tkinter import Tk
root = Tk()
root.configure(bg='white')
root.attributes('-transparentcolor', 'white')
root.attributes('-topmost', True)
root.mainloop()

我认为代码不言自明。(取决于操作系统,适用于Windows(

最新更新