I have an app that uses <FocusOut>
binding to automatically save the edits in an Entry
to a list.
There is no problem saving the Entry
text when using TAB
to navigate through the Entries or when I click on another Entry, but If I change the text on one Entry and then if I mouse-click on a ListBox
in another frame, <FocusOut>
doesn't work on the last selected Entry and the information in it is not registered.
How can I avoid this without resorting to a Save
button on the GUI? For every selection in the ListBox
there are different Entry
boxes, so the user would have to press the Save
button numerous times. I would like to avoid that.
It looks like you want to get the updated text realtime. What I do in such a case is use the 'KeyRelease'
-binding. Simple, effective enrtry- specific and works instantly.
In concept:
win = Tk()
def dosomething(*args):
# update the corresponding text anywhere, save your text, whatever
print(entry.get())
entry = Entry()
entry.bind("<KeyRelease>", dosomething)
entry.pack()
win.mainloop()
In action:
M
Mo
Mon
Monk
Monke
Monkey
Monkey
Monkey e
Monkey ea
Monkey eat
Monkey eats
Monkey eats
Monkey eats b
Monkey eats ban
Monkey eats ban
Monkey eats bana
Monkey eats banan
Monkey eats banana
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With