Tkcalendar clear DateEntry after moving focus
The DateEntry
is set to validate the entry content on focus out (the validate
option is set to 'focusout') and if the content is not a valid date, today's date is put in the entry. The idea being to always have a valid date inside the entry.
You can therefore simply get rid of this behavior by setting
myDateEntry.configure(validate='none')
This way the entry content is no longer validated on focus out, however it will still be validated when clicking on the drop-down button so there shouldn't be issue with invalid dates when displaying the calendar.
The easiest way is to delay your delete
method by 1 ms:
def clearDateEntry(): clearButton.focus_set() root.after(1, myDateEntry.delete, 0,END)