Make a Tkinter Toplevel active

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

    ...however, I have to click in the window first so that it becomes active, and then it works.

    I just encountered this problem and while I was researching a solution, I found this thread. I'm using Windows 7 Professional. All I did was call both grab_set() and focus() and it solved the problem for me. You already have finalRoot.grab_set(), just add:

    finalRoot.focus()
    

    It worked in my case.

提交回复
热议问题