Disable focus for tkinter widgets?

后端 未结 1 1437
挽巷
挽巷 2021-01-20 20:50

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条回答
  • 2021-01-20 21:35

    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.

    0 讨论(0)
提交回复
热议问题