Is there a way to detect a FocusOut event on 2 widgets in python
If I understand you correctly, you want the DateEntry
not to be destroyed when you click open the calendar. That is doable by checking your current focus and pass
if the current focus is a Calendar
object.
import tkinter as tkfrom tkcalendar import DateEntry, Calendardef check_focus(event): current = root.focus_get() if not isinstance(current,Calendar): cal.destroy()root = tk.Tk()cal = DateEntry(root, year=2010)cal.pack(padx=10, pady=10)cal.bind('<FocusOut>', check_focus)tk.Button(root,text="Click").pack()root.mainloop()
Try pressing tab to change focus and see.