4

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alexandru Antochi
  • 1,295
  • 3
  • 18
  • 42
  • Please provide a [Minimal, Complete, and Verifiable Example (MCVE)](http://www.stackoverflow.com/help/mcve). Assuming that the listbox takes focus (which might not be true in all cases), then `` will work as you expect. – Bryan Oakley Oct 14 '16 at 11:48

1 Answers1

3

Realtime edit / save text instead

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()

enter image description here

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
Community
  • 1
  • 1
Jacob Vlijm
  • 3,099
  • 1
  • 21
  • 37