Search code examples
pythontkinter

Putting a Tkinter window below all other windows


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.


Solution

  • 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.