-
Notifications
You must be signed in to change notification settings - Fork 949
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 datetime and time pickers #2715
Conversation
Ready for review! :) |
This looks great! I've played around with the interface. I've not looked at the code at all.
In the DatetimePicker, there's some strange behaviour around zoned date times and offset-native datetimes. As far as I can tell (I haven't looked at the code), setting the value by playing around with the UI control sets a time-zone aware datetime (at least on Chrome). However, I can then set the value manually via an assignment to The most straightforward way to exploit this discrepancy to cause an exception is:
import ipywidgets as widgets
import datetime
dt = widgets.DatetimePicker()
dt
dt.value.tzname() # => 'GMT' for me
dt.max = datetime.datetime(2018, 1, 1) gives:
It feels like the only sensible way to deal with this is to either only allow zoned datetimes or offset-native datetimes, but not a mix. From your entry in the documentation, it looks like you expect the user to select a zoned datetime, not an offset-native one. Maybe we could introduce a new traitlet, or allow customization of the current one? |
Seems reasonable. I've also added a naive picker in |
@pbugnion I've added a separate picker for naive datetimes ( |
Now green ✔️ |
From ipywidgets meeting today: we should have further discussion about serialization formats. CC @SylvainCorlay and @vidartf |
Hi, I was looking for a |
It is currently available in the package ipydatetime. The hope/plan is to get this into core ipywidgets (since it is a "standard" browser control), but I need to update the PR with the latest changes from that package. |
This should be ready now. @SylvainCorlay I didn't touch datetime serialization format. Let's discuss any changes in a followup issue/PR. For context: we were discussing using a different format for serialization, either Unix timestamp or Isoformat string (full version or limited to Python stdlib supported version). |
Don't merge until I've fixed the schemas becoming binary |
Marked as draft for now, then. |
Fixed 👍 |
@jtpio - is this good to merge? |
If anyone wants to try this branch on Binder: https://mybinder.org/v2/gh/vidartf/ipywidgets/datetime?urlpath=lab/tree/docs/source/examples/ |
* Called when the model is changed. The model may have been | ||
* changed by another view or by a state update from the back-end. | ||
*/ | ||
update2(model?: Backbone.Model, options?: any): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use a more descriptive name than update2
for this method?
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
# Copyright (c) Vidar Tonaas Fauske. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a couple of these headers here and below could be updated to match the existing ones.
@vidartf mind rebasing on the latest |
Also adds some attributes to DatePicker for consistency.
Co-authored-by: Jeremy Tuloup <[email protected]>
@jtpio Rebased, and all green ✔️ |
@jtpio, is this good to go in? |
I think so yes. In the dev meeting last week we had decided to wait until a couple of dependency update PRs were merged and a new alpha release cut. So it should be good to go now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Resolves #2548