1

I want a tkinter window that isn't fullscreen. Normally, if I click outside of the window, the window will automatically go "underneath" the window I just clicked on. How can I make this window stay on the front of the screen, even when I click outside of it?

Justin Cheng
  • 153
  • 1
  • 8
  • 6
    Maybe you need `root.wm_attributes("-topmost", True)`? – jizhihaoSAMA Jun 17 '20 at 02:36
  • 4
    Does this answer your question? [How to keep the window focus on new Toplevel() window in Tkinter?](https://stackoverflow.com/questions/15944533/how-to-keep-the-window-focus-on-new-toplevel-window-in-tkinter) – MeetTitan Jun 17 '20 at 02:52
  • 1
    @MeetTitan That isn't a duplicate because OP's questions is asking how to do it forever. The question you linked is similar, but not duplcate. – 10 Rep Jun 17 '20 at 02:54

1 Answers1

0

You can put it to the top every second by using a loop that occurs every millisecond.

from tkinter import *

window = Tk()
def main_loop():
    window.wm_attributes("-topmost", True)
    window.focus()
    window.after(1, main_loop)
main_loop()
window.mainloop()
Zoe
  • 27,060
  • 21
  • 118
  • 148
10 Rep
  • 2,217
  • 7
  • 19
  • 33