Spaces:
Running
Running
import gradio as gr | |
from date_rangeslider import RangeSlider | |
from pathlib import Path | |
text = "## The selected date range is: {min} to {max}" | |
with gr.Blocks() as demo: | |
with gr.Tabs(): | |
with gr.Tab("Demo"): | |
gr.Markdown("""## π Date RangeSlider | |
## Drag either end and see the selected date range update in real-time. | |
""") | |
range_slider = RangeSlider( | |
minimum="2023-01-01", | |
maximum="2024-12-31", | |
value=("2023-01-01", "2024-12-31") | |
) | |
range_ = gr.Markdown(value=text.format(min="2023-01-01", max="2024-12-31")) | |
range_slider.change( | |
lambda s: text.format(min=s[0], max=s[1]), | |
range_slider, | |
range_, | |
show_progress="hide", | |
trigger_mode="always_last" | |
) | |
gr.Examples([ | |
("2023-03-01", "2023-06-30"), | |
("2023-07-01", "2023-12-31") | |
], inputs=[range_slider]) | |
if __name__ == "__main__": | |
demo.launch() |