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

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.2.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.2-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for gradio_flatpickr_calendar-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3a2d19eb156acdcfdc45e4da05bfe3ccd2675245c79dbfcb51c793e5a38842da
MD5 b31eabdb778a792cd9b36d248f281321
BLAKE2b-256 d1f2ec9f2b74e79f425ca9dd200fa0bf600b5272ef44740df799182bd718457a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gradio_flatpickr_calendar-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bdd89b1c6c5efc88fe3f358b12936b95962f31fed35c4addd2f2efc4f65302d7
MD5 6b54b19766dce12b42cb64780a441c88
BLAKE2b-256 094b6204b7818e072fadd99c47b092e41cb507d6dbd522784ea10b2e79f9f052

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