How To Set Focus For Tkinter Widget?
I have a simple Python + Tkinter application that displays a list of 10 items: import Tkinter, ttk list = ttk.Treeview( Tkinter.Tk() ) list.pack( fill = Tkinter.BOTH, expand = 1 )
Solution 1:
Found a solution at last - seems that Treeview
widget need to be set focus two times: first for the widget itself, and second for an item:
list.selection_set( items[ 0 ] )
list.focus_set()
list.focus( items[ 0 ] ) # this fixes a problem.
Post a Comment for "How To Set Focus For Tkinter Widget?"