Disable focus for tkinter widgets?

最后都变了- 提交于 2020-01-11 10:46:06

问题


How can I make a widget that will not get the focus ever in tkinter? For example, a button that when I will press TAB the focus will skip on him


回答1:


I have found some time to provide a working example:

import Tkinter
import tkMessageBox

root = Tkinter.Tk()

but1 = Tkinter.Button(root, text ="Button 1")
but1.pack()

butNoFocus = Tkinter.Button(root, text ="Button no focus", takefocus = 0)
butNoFocus.pack()

but2 = Tkinter.Button(root, text = "Button 2")
but2.pack()

root.mainloop()

takefocus option set to 0 will disable tab focus on created button.



来源:https://stackoverflow.com/questions/39703766/disable-focus-for-tkinter-widgets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!