In Tkinter how do i remove focus from a widget?

后端 未结 6 981
余生分开走
余生分开走 2021-02-08 13:37

I\'d like to remove focus from a widget manually.

6条回答
  •  粉色の甜心
    2021-02-08 14:25

    • Set focus to another widget to remove focus from the target widget is a good idea. There are two methods for this: w.focus_set() and w.focus_force(). However, method w.focus_force() is impolite. It's better to wait for the window manager to give you the focus. Setting focus to parent widget or to the root window removes focus from the target widget.
    • Some widgets have takefocus option. Set takefocus to 0 to take your widget out of focus traversal (when user hits key).

提交回复
热议问题