panel icon indicating copy to clipboard operation
panel copied to clipboard

Daterangepicker

Open samuelyeewl opened this issue 2 years ago • 6 comments

I added a DateRangePicker widget, for when you only want a datetime.date range rather than a datetime.datetime range.

samuelyeewl avatar Oct 06 '21 19:10 samuelyeewl

@samuelyeewl Do you still want to add this? I think it's reasonable to add although we might consider making DatetimerRangePicker more configurable.

philippjfr avatar Oct 08 '21 09:10 philippjfr

Yes, I think it would be useful to have a widget that returns a datetime.date rather than datetime.datetime object (DatetimeRangePicker already has a disable_time parameter, but still returns a datetime with time = 12:00, which can lead to inconsistencies). I had to fix a bug in the tests and added the reference notebook. However, I think the DateRangePicker needs a little more work as it shows some of the layout parameters from the DatetimeRangePicker (which I subclassed) that are no longer relevant (enable_seconds, military_time). Any thoughts on how to do this?

samuelyeewl avatar Oct 08 '21 13:10 samuelyeewl

I haven't looked at the details here, but if you are trying to make a parameter not appear and not be used in a subclass, you can redefine it with the same type but a negative precedence and readonly=True (e.g. x=param.Integer(0, precedence=-1, readonly=True).

jbednar avatar Oct 08 '21 14:10 jbednar

I haven't looked at the details here, but if you are trying to make a parameter not appear and not be used in a subclass

That seems like a weird approach honestly, you should instead create a baseclass that has the parameters you do want to be shared and then subclass from that.

philippjfr avatar Oct 08 '21 14:10 philippjfr

Or in this case it might be reasonable to invert the hierarchy and have DatetimeRangePicker inherit from your DateRangePicker.

philippjfr avatar Oct 08 '21 14:10 philippjfr

That seems like a weird approach honestly, you should instead create a baseclass that has the parameters you do want to be shared and then subclass from that.

Good point; that's the right long-term approach. My answer only applies if you are unwilling or unable to do a refactor like that.

jbednar avatar Oct 08 '21 15:10 jbednar

I need this to to support param.DateRange parameters.

MarcSkovMadsen avatar Nov 10 '23 05:11 MarcSkovMadsen

Closes #5844

MarcSkovMadsen avatar Nov 10 '23 05:11 MarcSkovMadsen

Superseded by https://github.com/holoviz/panel/pull/6027

philippjfr avatar Dec 11 '23 14:12 philippjfr