Make a Tkinter Toplevel active

前端 未结 6 1386
灰色年华
灰色年华 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:43

    None of the above suggestions worked for me on Mac OS El Capitan, but this does:

    class Window(Tk.Toplevel):
        ...
        def setActive(self):
            self.lift()
            self.focus_force()
            self.grab_set()
            self.grab_release()
        ...
    

提交回复
热议问题