GitXplorerGitXplorer
f

gradio-calendar

public
10 stars
0 forks
5 issues

Commits

List of commits on branch main.
Unverified
854064c12bd8c4cabd520be113ac0b70befa48f4

version 5 compatibility

ffreddyaboulton committed 3 months ago
Unverified
a38d2a2f138f5644dbb85c6804e1f0c2ef34f237

Add links

ffreddyaboulton committed a year ago
Unverified
ae6a35e8cf34135901e86d6c4b74c07080823181

Add code

ffreddyaboulton committed a year ago
Verified
d11457198df498f21917064b08b25edd950ea8c2

Initial commit

ffreddyaboulton committed a year ago

README

The README file for this repository.

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
"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
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 | None
) -> str | datetime.datetime | None:
    return value