Saïd Maanan
Saïd Maanan

Reputation: 697

Choose date within a range using ipywidgets Date Picker

I need to create a widget that would allow the user to choose a date between two dates, say datetime.date(2021, 1, 1) and datetime.date(2023, 12, 31), and from the official documentation of ipywidgets I could not find anything more than this:

date_picker = widgets.DatePicker(
    description='Pick a Date',
    disabled=False,
)

Can someone please help me add constraints to the widgets? Thanks.

Upvotes: 0

Views: 1631

Answers (1)

IvanD
IvanD

Reputation: 8321

This should work:

start_date = widgets.DatePicker(description='Start Date', disabled=False, value = datetime.date(2021,1,1))
end_date = widgets.DatePicker(description='End Date', disabled=False, value = datetime.date(2023,12,31))

Upvotes: 1

Related Questions