How to recognize the selected entry

Asked

Viewed 41 times

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 enter the value that is inside a button in this selected field.

Tela

1 answer

2


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

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

If '1' is the value to be inserted. The process would be the same for the other buttons, then changing only the value to be inserted. In this context I would advise you to create a function that contains all the buttons on your Keyboard.

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

In this way their input objects could associate themselves both to the same function that contains the settings of the buttons, so that when realizing which one is in focus, they would change which entry they must refer to.

example of syntax for bind:

entry.bind('<FocusIn>', keyboard)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.