Check if Entry widget is selected Check if Entry widget is selected tkinter tkinter

Check if Entry widget is selected


There is always a widget with the keyboard focus. You can query that with the focus_get method of the root window. It will return whatever widget has keyboard focus. That is the window that should receive input from your keypad.


You can use events and bindigs to catch FocusIn events for your entries.

entry1 = Entry(root)entry2 = Entry(root)def callback_entry1_focus(event):    print 'entry1 focus in'def callback_entry2_focus(event):    print 'entry2 focus in'entry1.bind("<FocusIn>", callback_entry1_focus)entry2.bind("<FocusIn>", callback_entry2_focus)