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?
Asked
Active
Viewed 288 times
1
-
6Maybe you need `root.wm_attributes("-topmost", True)`? – jizhihaoSAMA Jun 17 '20 at 02:36
-
4Does 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 Answers
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 stands with Ukraine
- 25,310
- 18
- 114
- 149
10 Rep
- 2,156
- 7
- 17
- 31