Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to clear value of DatetimePicker #3990

Merged
merged 5 commits into from
Oct 14, 2022

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Oct 12, 2022

Fixes #3975

This PR will make it possible to clear the value of DatetimePicker.

Example:

import panel as pn
from datetime import datetime

pn.extension()

time_widget = pn.widgets.DatetimePicker()
btn = pn.widgets.Button(name="click")

@pn.depends(btn, watch=True)
def tmp(*event):
    if time_widget.value:
        time_widget.value = None
    else:
        time_widget.value = datetime.today()


pn.Column(btn, time_widget).servable()
screenrecord-2022-10-12_18.41.40.mp4

TODO:

  • Write unit test for it
  • Add support for other np.nan / pd.NaT

@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

Merging #3990 (840b44e) into master (a5bd963) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3990      +/-   ##
==========================================
- Coverage   83.74%   83.70%   -0.05%     
==========================================
  Files         223      223              
  Lines       32971    33080     +109     
==========================================
+ Hits        27611    27689      +78     
- Misses       5360     5391      +31     
Flag Coverage Δ
ui-tests 37.55% <100.00%> (+0.59%) ⬆️
unitexamples-tests 74.76% <16.21%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
panel/models/datetime_picker.py 100.00% <100.00%> (ø)
panel/tests/ui/widgets/test_input.py 99.47% <100.00%> (+0.05%) ⬆️
panel/tests/ui/io/test_convert.py 95.37% <0.00%> (-3.49%) ⬇️
panel/pane/image.py 79.53% <0.00%> (-0.66%) ⬇️
panel/io/state.py 69.76% <0.00%> (-0.50%) ⬇️
panel/io/pyodide.py 0.00% <0.00%> (ø)
panel/command/convert.py 31.42% <0.00%> (ø)
panel/tests/test_server.py 99.80% <0.00%> (+<0.01%) ⬆️
panel/widgets/tables.py 88.40% <0.00%> (+0.09%) ⬆️
panel/io/resources.py 86.80% <0.00%> (+0.09%) ⬆️
... and 5 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@hoxbro hoxbro marked this pull request as ready for review October 13, 2022 15:57
Copy link
Member

@philippjfr philippjfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@philippjfr philippjfr merged commit c1afabc into master Oct 14, 2022
@philippjfr philippjfr deleted the clear_value_datetimepicker branch October 14, 2022 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clearing value of a DatetimePicker
2 participants