Skip to main content

this is date picker for streamlit

Project description

Streamlit DatePicker

PyPI GitHub GitHub issues GitHub pull requests

Project Introduction

streamlit-date-picker is a date picker designed for use with Streamlit. It allows users to easily select a range of dates and times.

Try out a demo here: Streamlit App

Streamlit Date Picker

Installation

Install the package using the following command:

pip install streamlit-date-picker

Usage

import streamlit as st
from datetime import datetime, timedelta

from streamlit_date_picker import date_range_picker, date_picker, PickerType

st.title('Streamlit Date Picker')
st.subheader('Date Range Picker')
st.markdown("### 1.Time Range Picker")
default_start, default_end = datetime.now() - timedelta(minutes=30), datetime.now()
refresh_value = timedelta(minutes=30)
date_range_string = date_range_picker(picker_type=PickerType.time,
                                      start=default_start, end=default_end,
                                      key='time_range_picker',
                                      refresh_button={'is_show': True, 'button_name': 'Refresh Last 30 Minutes',
                                                      'refresh_value': refresh_value})
if date_range_string:
    start, end = date_range_string
    st.write(f"Time Range Picker [{start}, {end}]")

st.markdown("### 2.Date Range Picker")
default_start, default_end = datetime.now() - timedelta(days=1), datetime.now()
refresh_value = timedelta(days=1)
date_range_string = date_range_picker(picker_type=PickerType.date,
                                      start=default_start, end=default_end,
                                      key='date_range_picker',
                                      refresh_button={'is_show': True, 'button_name': 'Refresh Last 1 Days',
                                                      'refresh_value': refresh_value})
if date_range_string:
    start, end = date_range_string
    st.write(f"Date Range Picker [{start}, {end}]")

st.markdown("### 3.Week Range Picker")
default_start, default_end = datetime.now() - timedelta(days=7), datetime.now()
refresh_value = timedelta(days=7)
date_range_string = date_range_picker(picker_type=PickerType.week,
                                      start=default_start, end=default_end,
                                      key='week_range_picker',
                                      refresh_button={'is_show': True, 'button_name': 'Refresh Last 1 Week',
                                                      'refresh_value': refresh_value})
if date_range_string:
    start, end = date_range_string
    st.write(f"Week Range Picker [{start}, {end}]")

st.markdown("### 4.Month Range Picker")
default_start, default_end = datetime.now() - timedelta(days=30), datetime.now()
refresh_value = timedelta(days=30)
date_range_string = date_range_picker(picker_type=PickerType.month,
                                      start=default_start, end=default_end,
                                      key='month_range_picker',
                                      refresh_button={'is_show': True, 'button_name': 'Refresh Last 1 Month',
                                                      'refresh_value': refresh_value})
if date_range_string:
    start, end = date_range_string
    st.write(f"Month Range Picker [{start}, {end}]")

st.markdown("### 5.Year Range Picker")
default_start, default_end = datetime.now() - timedelta(days=365), datetime.now()
refresh_value = timedelta(days=365)
date_range_string = date_range_picker(picker_type=PickerType.year,
                                      start=default_start, end=default_end,
                                      key='year_range_picker',
                                      refresh_button={'is_show': True, 'button_name': 'Refresh Last 1 Year',
                                                      'refresh_value': refresh_value})
if date_range_string:
    start, end = date_range_string
    st.write(f"Year Range Picker [{start}, {end}]")

st.divider()

st.subheader('Date Picker')
default_value = datetime.now()
select_date = date_picker(picker_type=PickerType.time, value=default_value, key='date_picker')

if select_date:
    st.write(f"Date Picker: {select_date}")

Parameter

Range Picker

  • picker_type: Default picker type, type: str, options: time, date, week, month, quarter, year.
  • key: Picker key, default value: None.
  • start: Default start datetime, type: datetime, default value: datetime.now().
  • end: Default end datetime, type: int, default value: datetime.now().
  • refresh_button: Refresh button configuration, type: {'is_show': bool, 'button_name': str, 'refresh_value': datetime}, default values: None. When the button is clicked, it refreshes the selected time range.
  • The return value of datetime_range_picker is of type str.

Date Picker

  • picker_type: Default picker type, type: str, options: time, date, week, month, quarter, year.
  • value: Default value, type: datetime, default value: datetime.now().
  • key: Picker key, default value: None.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_date_picker-0.0.4b1.tar.gz (939.7 kB view details)

Uploaded Source

Built Distribution

streamlit_date_picker-0.0.4b1-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_date_picker-0.0.4b1.tar.gz.

File metadata

File hashes

Hashes for streamlit_date_picker-0.0.4b1.tar.gz
Algorithm Hash digest
SHA256 b3f33e10b615b69d12c096bb5ba27489af0f97d02f2ce061e9df39824627123d
MD5 0fa22ec6beda20aedb55aad94a515edb
BLAKE2b-256 dccc9fb6184d6bc5ce84ace3e62cdd649b8170b8b073d563ee4b0759d4296289

See more details on using hashes here.

File details

Details for the file streamlit_date_picker-0.0.4b1-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_date_picker-0.0.4b1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2521b3dfc0ea9194d8098bc5f93954f4b42f8e1b67a8622885ea2154636281f
MD5 edde8074fbe42820f30fd846eb5a2a29
BLAKE2b-256 f460914b3032ad95969cbbc35f73d41dfa911f6cbba993eba3a5e2dd5f45106a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page