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.5.tar.gz (2.2 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.5-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for gradio_flatpickr_calendar-0.0.5.tar.gz
Algorithm Hash digest
SHA256 92311f8578e0a56e96e475f7ec2a314ceea5d954b3510a4f7e97be10188278a7
MD5 ff345e6e9aa15e0f156ba895689011f7
BLAKE2b-256 7bac84cb9c54af2e14ae37350366ff87b0bf299f129538dee293e7b35151945e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gradio_flatpickr_calendar-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 bc097d8b8a63caa568a345b8e2f239c9033ccc3dd6e9a95823c36a6921db148f
MD5 f97265989edf7110888a32e229935843
BLAKE2b-256 3bd1bf7bb39000437ec81c98533aad8d74e80deb615ab44acd576e8719862e2d

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