Hello stackoverflowers,
I need an entry which calls a function (that reads what was put in that entry) whenever any character was put in it (<Key>
is good enough for me).
However, the problem I’m facing is that, as far as I understand, this function is called too early, so that entry.get() doesn’t see what was put in that entry yet.
Here’s an example of code:
from tkinter import *
def something_was_put(event):
print(entry.get())
root = Tk()
root.geometry('400x400')
entry = Entry(root)
entry.pack()
entry.bind('<Key>', something_was_put)
root.mainloop()
So, for example, if I put “5”, it prints an empty line. If I then put “6” (in an entry there’s “56” now), it prints “5” etc.
Is there any way to fix that, so it prints the whole text in an entry?
Thanks in advance
CzarnYU_owca is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.