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]:
    print("prediction")
    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.4.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.4-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for gradio_flatpickr_calendar-0.0.4.tar.gz
Algorithm Hash digest
SHA256 d6fd14b535281267c9c8dd3d393b7b45ad42f44a046a23da5b7b268eb9051112
MD5 6aec9689043cf6a1382974ea25cf222f
BLAKE2b-256 d1deaf6c8cf1d82c5c41206fbf81f1d88cd6d2e16f13f0e6f33a96534ab2d43e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gradio_flatpickr_calendar-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ea49e009a48f60895094bd4840706c37e5f3ed8251af0c12a5f676d8b4d39939
MD5 be56e5e66b0f4e9a904420398fb667e6
BLAKE2b-256 34678c53574f6600650986010cfb0e443341e22d9b52eda2928bb4a299bd0899

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