简体   繁体   中英

Tkinter: How to get event listener when entry box is deselected?

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM