Skip to main content

Gradio component for selecting dates or ranges of dates with a Flatpickr calendar 📆

Project description

gradio_flatpickr_calendar

PyPI - Version Static Badge

Gradio component for selecting dates or ranges of dates with a Flatpickr calendar 📆

Installation

pip install gradio_flatpickr_calendar

Usage

import gradio as gr
from gradio_flatpickr_calendar import Calendar
import datetime


def predict(date: datetime.datetime | tuple[datetime.datetime, datetime.datetime]) \
        -> datetime.datetime | tuple[datetime.datetime, datetime.datetime]:
    return date


demo = gr.Interface(fn=predict,
                    inputs=[Calendar(label="Select a date or a range of dates",
                                     info="Click to bring up the calendar.",
                                     mode="range", type="datetime")],
                    outputs=Calendar(label="Selected date(s)", info="Here are the date(s) you selected:"),
                    examples=["2023-01-01", ("2023-01-01", "2023-12-11")],
                    cache_examples=True,
                    title="Choose a date")

if __name__ == "__main__":
    demo.launch()

Calendar

Initialization

name type default description
value
str | datetime.datetime
None None
type
"string" | "datetime"
"datetime" None
mode
"date" | "range"
"date" None
label
str | None
None None
info
str | None
None None
show_label
bool | None
None None
container
bool
True None
scale
int | None
None None
min_width
int | None
None None
interactive
bool | None
None None
visible
bool
True None
elem_id
str | None
None None
elem_classes
list[str] | str | None
None None
render
bool
True None
load_fn
typing.Optional[typing.Callable[..., typing.Any]][
    typing.Callable[..., typing.Any][Ellipsis, typing.Any],
    None,
]
None None
every
float | None
None None
date_format
str
"%Y-%m-%d" None

Events

name description
change
input
submit

User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

  • When used as an Input, the component only impacts the input signature of the user function.
  • When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

  • As output: Is passed, the preprocessed input data sent to the user's function in the backend.
  • As input: Should return, the output data received by the component from the user's function in the backend.
def predict(
    value: str
   | datetime.datetime
   | tuple[str, str]
   | tuple[datetime.datetime, datetime.datetime]
   | None
) -> str
   | datetime.datetime
   | tuple[str, str]
   | tuple[datetime.datetime, datetime.datetime]
   | None:
    return value

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

gradio_flatpickr_calendar-0.0.3.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gradio_flatpickr_calendar-0.0.3-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file gradio_flatpickr_calendar-0.0.3.tar.gz.

File metadata

File hashes

Hashes for gradio_flatpickr_calendar-0.0.3.tar.gz
Algorithm Hash digest
SHA256 bfb955572d2f74365f614ce331ce8a013ed03578998d34ab8d0ae3b289c870d1
MD5 c4a398f75500e7456a6ffdf0435967a3
BLAKE2b-256 f1a55d65f600a2585a5d27fa00dcb48ec27ae75e4ab273e827a4a1d7438d7063

See more details on using hashes here.

File details

Details for the file gradio_flatpickr_calendar-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_flatpickr_calendar-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bde1c125875f3879c904edef7744e35216dd3b011b1c30f1e9737bb210410ce0
MD5 b7747475763053565726b9cf79d31fb1
BLAKE2b-256 1f3a1f81c3ca6196d34c6c7ce4ebd210bdb2e9dd166d9d4aa1fe96837fa946f0

See more details on using hashes here.

Supported by

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