menu

Questions & Answers

Make the tkinter window always on back on windows

I am trying to make a desktop overlay for windows.

Here is my code:

from tkinter import *
from win32gui import SetWindowPos
from win32con import *
from win32api import Sleep
from threading import Thread


class Desktop:
    def Desktop(self):
        self.desktoptk = Tk()
        tk = self.desktoptk


        tk.overrideredirect(True)
        
        tk.geometry(f'{tk.winfo_screenwidth()}x{tk.winfo_screenheight()}+0+0')
        def sendtoback():
            hwnd = tk.winfo_id()
            print(hwnd)
            def send():
                while True:
                    Sleep(10)
                    SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE)


            Thread(target=send).start()
            

        tk.after(200, sendtoback)
        bg = PhotoImage(file=R'data\bg.png')
        Bg = Label(image=bg)
        Bg.image = bg
        Bg.place(x=0, y=0)
        tk.mainloop()
Desktop().Desktop()

I am was not trying to solve it, because i didn't found it and i don't have any ideas how.

I need to make my tkinter window to be always on back (opposite of always on top).

Comments:
2023-01-20 00:00:14
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answers(0) :