0

Just the title. I have an entry box that needs to be rounded to 10, but I want it to happen the moment another entry box is selected.

The only event listener I can find to do with tkinter entry boxes is attatching a StringVar and tracing it, but that doesn't seem to do what I want here as I don't want the changes to happen while typing.

1 Answers1

0

You are looking for the <FocusOut> event.

def some_func(event):
    print("The entry has lost focus")
entry = tk.Entry(...)
entry.bind("<FocusOut>", some_func)
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Is there anyway to send parameters to this, without it being called on program launch? I.e. I want to use: ``` entryDx.bind("",round_floor_ten(variable_id)) ``` but when I do that, the round_floor_ten function is called when the code is loaded. function is defined as: ``` def round_floor_ten(*args): ``` –  May 27 '21 at 16:53
  • @Frogglet: see https://stackoverflow.com/questions/5767228/why-is-the-command-bound-to-a-button-or-event-executed-when-declared – Bryan Oakley May 27 '21 at 16:58