This is my code:
root = Tk()
def mytest():
var = entry.get()
print(var)
return True
entry = Entry(root, validate="key", validatecommand=mytest)
entry.pack()
root.mainloop()
I was trying to validate each letter that user enters.
The problem is when I use the get()
method to get the current letters, I get the letters up to the previous input.
For example, assuming I am typing in the word "abc"
- When I first typed
"a"
, it will print nothing. - When I add
"b"
, it will print"a"
- When I continue to type
"c"
, it will print"ab"
Why this strange behaviour?