我想创建一个模拟桌面背景的tkinter应用程序.我目前的主要问题是把tkinter应用程序放在桌面图标后面.我已经try 过wm_attributes
和ctypes.windll.user32.SetLayeredWindowAttributes
,但它仍然将主窗口绘制在桌面图标之上.
我如何才能强制我的tkinter应用程序始终停留在桌面图标后面?(同时仍处于交互状态:d)
对于我试图实现的目标,这是一个小小的目标:
import tkinter as tk
import ctypes
root = tk.Tk()
# Set the window to be behind everything <-- not working
ctypes.windll.user32.SetLayeredWindowAttributes(root.winfo_id(), 0, 0, 1)
root.wm_attributes('-topmost', False)
# Create a canvas to display the GUI
canvas = tk.Canvas(root)
canvas.pack()
# Add some widgets to the canvas
label = tk.Label(canvas, text="This is a Tkinter screen behind everything.")
label.pack()
# Start the GUI loop
root.mainloop()