# `gradio_calendar`
<a href="https://pypi.org/project/gradio_calendar/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_calendar"></a> <a href="https://github.com/freddyaboulton/gradio-calendar/issues" target="_blank"><img alt="Static Badge" src="https://img.shields.io/badge/Issues-white?logo=github&logoColor=black"></a> <a href="https://huggingface.co/spaces/freddyaboulton/gradio_calendar/discussions" target="_blank"><img alt="Static Badge" src="https://img.shields.io/badge/%F0%9F%A4%97%20Discuss-%23097EFF?style=flat&logoColor=black"></a>
Gradio component for selecting dates with a calendar 📆
## Installation
```bash
pip install gradio_calendar
```
## Usage
```python
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
<table>
<thead>
<tr>
<th align="left">name</th>
<th align="left" style="width: 25%;">type</th>
<th align="left">default</th>
<th align="left">description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>value</code></td>
<td align="left" style="width: 25%;">
```python
str | datetime.datetime
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>type</code></td>
<td align="left" style="width: 25%;">
```python
"string" | "datetime"
```
</td>
<td align="left"><code>"datetime"</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>label</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>info</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>show_label</code></td>
<td align="left" style="width: 25%;">
```python
bool | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>container</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>scale</code></td>
<td align="left" style="width: 25%;">
```python
int | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>min_width</code></td>
<td align="left" style="width: 25%;">
```python
int | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>interactive</code></td>
<td align="left" style="width: 25%;">
```python
bool | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>visible</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>elem_id</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>elem_classes</code></td>
<td align="left" style="width: 25%;">
```python
list[str] | str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>render</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>load_fn</code></td>
<td align="left" style="width: 25%;">
```python
typing.Optional[typing.Callable[..., typing.Any]][
typing.Callable[..., typing.Any][Ellipsis, typing.Any],
None,
]
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>every</code></td>
<td align="left" style="width: 25%;">
```python
float | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
</tbody></table>
### 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.
```python
def predict(
value: str | datetime.datetime | None
) -> str | datetime.datetime | None:
return value
```
Raw data
{
"_id": null,
"home_page": null,
"name": "gradio-calendar",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "calendar, forms, gradio-custom-component, gradio-template-Fallback, time",
"author": null,
"author_email": "YOUR NAME <YOUREMAIL@domain.com>",
"download_url": "https://files.pythonhosted.org/packages/47/4a/2103583da86778756f8b34de1054d08aba68728ed61a8708ed87c1f3ed17/gradio_calendar-0.0.6.tar.gz",
"platform": null,
"description": "\n# `gradio_calendar`\n<a href=\"https://pypi.org/project/gradio_calendar/\" target=\"_blank\"><img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/gradio_calendar\"></a> <a href=\"https://github.com/freddyaboulton/gradio-calendar/issues\" target=\"_blank\"><img alt=\"Static Badge\" src=\"https://img.shields.io/badge/Issues-white?logo=github&logoColor=black\"></a> <a href=\"https://huggingface.co/spaces/freddyaboulton/gradio_calendar/discussions\" target=\"_blank\"><img alt=\"Static Badge\" src=\"https://img.shields.io/badge/%F0%9F%A4%97%20Discuss-%23097EFF?style=flat&logoColor=black\"></a>\n\nGradio component for selecting dates with a calendar \ud83d\udcc6\n\n## Installation\n\n```bash\npip install gradio_calendar\n```\n\n## Usage\n\n```python\nimport gradio as gr\nfrom gradio_calendar import Calendar\nimport datetime\n\ndef is_weekday(date: datetime.datetime):\n return date.weekday() < 5\n\ndemo = gr.Interface(is_weekday, \n [Calendar(type=\"datetime\", label=\"Select a date\", info=\"Click the calendar icon to bring up the calendar.\")], \n gr.Label(label=\"Is it a weekday?\"),\n examples=[\"2023-01-01\", \"2023-12-11\"],\n cache_examples=True,\n title=\"Is it a weekday?\")\n\nif __name__ == \"__main__\":\n demo.launch()\n\n```\n\n## `Calendar`\n\n### Initialization\n\n<table>\n<thead>\n<tr>\n<th align=\"left\">name</th>\n<th align=\"left\" style=\"width: 25%;\">type</th>\n<th align=\"left\">default</th>\n<th align=\"left\">description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>value</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | datetime.datetime\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>type</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\n\"string\" | \"datetime\"\n```\n\n</td>\n<td align=\"left\"><code>\"datetime\"</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>info</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>container</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>scale</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>min_width</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>interactive</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>visible</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_id</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_classes</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>render</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>load_fn</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\ntyping.Optional[typing.Callable[..., typing.Any]][\n typing.Callable[..., typing.Any][Ellipsis, typing.Any],\n None,\n]\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>every</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nfloat | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n</tbody></table>\n\n\n### Events\n\n| name | description |\n|:-----|:------------|\n| `change` | |\n| `input` | |\n| `submit` | |\n\n\n\n### User function\n\nThe impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).\n\n- When used as an Input, the component only impacts the input signature of the user function.\n- When used as an output, the component only impacts the return signature of the user function.\n\nThe code snippet below is accurate in cases where the component is used as both an input and an output.\n\n- **As output:** Is passed, the preprocessed input data sent to the user's function in the backend.\n- **As input:** Should return, the output data received by the component from the user's function in the backend.\n\n ```python\n def predict(\n value: str | datetime.datetime | None\n ) -> str | datetime.datetime | None:\n return value\n ```\n \n",
"bugtrack_url": null,
"license": null,
"summary": "Gradio component for selecting dates with a calendar \ud83d\udcc6",
"version": "0.0.6",
"project_urls": {
"repository": "https://github.com/freddyaboulton/gradio-calendar",
"space": "https://huggingface.co/spaces/freddyaboulton/gradio_calendar"
},
"split_keywords": [
"calendar",
" forms",
" gradio-custom-component",
" gradio-template-fallback",
" time"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f8e52bdb914682a1b1b82e9d0079e68f02e13ad7dc8103431e545688c5432547",
"md5": "99c26fc8737ea69e48e18f575b704a2f",
"sha256": "2431b84ee2228be96770e907a478a4724cc36cc970a10e2b4209c85aa2373e2c"
},
"downloads": -1,
"filename": "gradio_calendar-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "99c26fc8737ea69e48e18f575b704a2f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1192624,
"upload_time": "2024-10-09T18:00:34",
"upload_time_iso_8601": "2024-10-09T18:00:34.904317Z",
"url": "https://files.pythonhosted.org/packages/f8/e5/2bdb914682a1b1b82e9d0079e68f02e13ad7dc8103431e545688c5432547/gradio_calendar-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "474a2103583da86778756f8b34de1054d08aba68728ed61a8708ed87c1f3ed17",
"md5": "8321e552d4ffe6951c0cb21acbf9dea9",
"sha256": "728addfc07c350d46b69459447eb1e390d87ada0ddaed3457bd78da480eca2ec"
},
"downloads": -1,
"filename": "gradio_calendar-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "8321e552d4ffe6951c0cb21acbf9dea9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 1236019,
"upload_time": "2024-10-09T18:00:37",
"upload_time_iso_8601": "2024-10-09T18:00:37.327570Z",
"url": "https://files.pythonhosted.org/packages/47/4a/2103583da86778756f8b34de1054d08aba68728ed61a8708ed87c1f3ed17/gradio_calendar-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-09 18:00:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "freddyaboulton",
"github_project": "gradio-calendar",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "gradio-calendar"
}