Skip to main content

Gradio component for selecting dates with a calendar 📆

Project description

gradio_calendar

PyPI - Version Static Badge Static Badge

Gradio component for selecting dates with a calendar 📆

Installation

pip install gradio_calendar

Usage

import gradio as gr
from gradio_calendar import Calendar
import datetime

def is_weekday(date: datetime.datetime):
    return date.weekday() < 5

demo = gr.Interface(is_weekday, 
    [Calendar(type="datetime", label="Select a date", info="Click the calendar icon to bring up the calendar.")], 
    gr.Label(label="Is it a weekday?"),
    examples=["2023-01-01", "2023-12-11"],
    cache_examples=True,
    title="Is it a weekday?")

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

Calendar

Initialization

name type default description
value
str | datetime.datetime
None None
type
Literal["string", "datetime"]
"datetime" 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
Callable[..., 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.

def predict(
    value: str | datetime.datetime | None
) -> str | 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_calendar-0.0.4.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

gradio_calendar-0.0.4-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gradio_calendar-0.0.4.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for gradio_calendar-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e4ea93cc7f6284bb8e547bb34d891776f1f0bebd320eae80bd644c0cd30694ce
MD5 4bc41de2e95305643886f7f19f121342
BLAKE2b-256 bbf75554af428f45d67c96ce0f0f43111dd548b30e9ed9a2815e0eba7185965c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for gradio_calendar-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 32f738ea94ed4dea1e4069a117d907fc3e8a2757fb2f4b0ce67a801f434928df
MD5 80302b5949fc38d16fe0cfa58987eb63
BLAKE2b-256 843b6e7868c0d2dc376ce030e7f7dbea27184416e307311f3e60851e164d0520

See more details on using hashes here.

Provenance

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