How to keep the window focus on new Toplevel() window in Tkinter?

后端 未结 3 1293
孤独总比滥情好
孤独总比滥情好 2020-12-20 16:27

I am currently writing a win32gui python27 application (I\'m running win7). I am wondering if it is possible to create a new window from my mainloop() and KEEPING the focus

3条回答
  •  忘掉有多难
    2020-12-20 16:29

    None of the above suggestions worked for me, on Mac OS El Capitan. But based on those hints, this does:

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

提交回复
热议问题