在 Tkinter 中,如何从小部件中移除焦点? [英] In Tkinter how do i remove focus from a widget?
本文介绍了在 Tkinter 中,如何从小部件中移除焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想手动移除小部件的焦点.
I'd like to remove focus from a widget manually.
推荐答案
您可以关注另一个虚拟小部件.
You can focus to another dummy widget.
编辑
from Tkinter import *
def callback():
print master.focus()
master = Tk()
e = Entry(master)
e.pack()
e.focus()
b = Button(master, text="get", width=10, command=callback)
b.pack()
master.mainloop()
将焦点放在不可聚焦"的小部件上会移除另一个小部件的焦点.
Focusing on a non-'focusable' widget will remove focus from another widget.
这篇关于在 Tkinter 中,如何从小部件中移除焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文