How to recognize the selected Entry

0

I have two data entries (password.entry, id.entry) and I want to make the program recognize which of these fields is clicked and insert the value that is inside a button in that selected field.

    
asked by anonymous 20.09.2018 / 18:28

1 answer

2

In order for the button to enter the value in the object, set the command so that:

Button(command=lambda: entry.insert(END,'1'))

Being '1' is the value to insert. The process would be the same for the other buttons, only changing the value to be inserted. In this context I would advise you to create a function that would hold all the buttons of your keyboard.

To recognize which of the input objects is in focus you would use a bind of type <FocusIn>

In this way, your input objects could both be associated with the same function that contains the button settings, so that when you notice which one is in focus, change what entry they should refer to.

syntax example for bind:

entry.bind('<FocusIn>', keyboard)
    
20.09.2018 / 18:58