I have a Tkinter window that I need to stay on top of everything else - including fullscreen windows.
Things I have tried:
root.attributes('-topmost', True)
before mainloop - doesn't work
self.root.wm_attributes("-topmost", True)
inside the class - doesn't work
root.overrideredirect(True)
before mainloop - works on Linux only
root.lift()
before mainloop - doesn't work
And finally, I set root.lift()
to be called repetitively:
class TestingGUI:
def __init__(self, root):
self.root = root
self.EnsureTop()
def EnsureTop(self):
root.lift()
root.after(5000, self.EnsureTop)`
This works in the sense that it successfully raises the window over any other windows I've manually toggled to be 'always on top', using e.g. Dexpot, but crucially it doesn't work for fullscreen applications.
Specifically, I need this to be shown over games, as it's an in-game music player. I'm fine with solutions that require some command to be used repetitively to ensure the window is called to the top again.
As TessellatingHeckler pointed out in the comments, it's not possible to ensure a window stays on top of another fullscreen one. I solved this by combining a looping root.lift()
and asking my users to run their applications in a borderless window.