optionally allow empty/whitespace values #76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale
Sometimes one might want to allow a
DateEntryto be blank, such as when building a form.As mentioned in #53 the behavior of automatically inserting a date on initialization / when clicking the
DateEntrycan be a little surprising, but is pretty easy to work around by using theEntry'ssetmethod.This PR would allow one to specify this behavior by passing in an optional kwarg
allow_emptywhen initializing aDateEntry, such that the widget would start off blank and could be left blank by deleting its contents.Changes
allow_emptykwarg to__init__,_allow_emptyattribute and considers it in_validate_dateEntryblank on init if_allow_empty == Truedrop_downto prevent attempting to parse an empty valueempty strings and whitespace are treated equally
Pros
set_dateandget_datestill complain if they find the empty value (this seems appropriate)Cons
This optional behavior isn't accounted for in the tests.I'm not very familiar with writing tests, but if you have suggestions/hints I'd be happy to try to add some coverage.