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

时间:2020-06-13 11:51:48

标签: python linux tkinter

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

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

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

1 个答案:

答案 0 :(得分:0)

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

from tkinter import Tk

root = Tk()

root.configure(bg='white')
root.attributes('-transparentcolor', 'white')
root.attributes('-topmost', True)

root.mainloop()

我认为代码可以说明一切。 (取决于OS,可在Windows上运行)