I’m trying to make a Tkinter window appear below all other windows.
I know how to make it appear over all other windows:
import tkinter as tk
root = tk.Tk()
root.attributes('-topmost', True)
root.mainloop()
But I’m trying to do the opposite of that – so that the window sits under all windows, on the desktop. -bottommost
isn’t a thing though, sadly.
1
You can set up an event binding to lower
the root
window whenever it’s focused:
import tkinter as tk
def send_to_back(_event) -> None:
root.lower()
root = tk.Tk()
root.lower() # start window in the back (may not be necessary)
root.bind('<FocusIn>', send_to_back)
if __name__ == '__main__':
root.mainloop()
FWIW, this won’t place the window below (behind?) icons on the desktop, but it should keep it below all other windows, including those not created by your tkinter app.
I’m trying to make a Tkinter window appear below all other windows.
Here is code:
Snippet:
import tkinter as tk
root = tk.Tk()
root.title("Keep Window on Top")
root.geometry("300x300")
top_window = tk.Toplevel(root)
top_window.title("Top Window")
top_window.geometry("200x200")
top_window.wm_attributes("-topmost", True)
root.mainloop()
The window sits under all windows.
1
tkinter manages only hierarchy of windows created by Tk, so You will need to use external libraries to manage system window level depth.
If You would like to You can minimalise window to taskbar, which in fact should also change display windows order.
import tkinter as tk
root = tk.Tk()
root.wm_state('iconic') #same as root.lower()
root.mainloop()
# CTRL+C or CTRL+X to KeyboardInterrupt
Qq Qqqq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1