Make a Tkinter Toplevel active

前端 未结 6 1388
灰色年华
灰色年华 2020-12-10 08:57

I am trying to make a Toplevel widget that is the active window on the screen (I want it so that if you press Enter, it exits the window. I already h

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 09:35

    Here is the code which worked for me

    root= tk.Tk()
    root.title("Main Window")
    top = tk.Toplevel()
    top.title("Topelevel Window")
    top.grab_set()  #for disable main window
    top.attributes('-topmost',True)  #for focus on toplevel
    root.mainloop()
    

提交回复
热议问题