Spaces:
Runtime error
Runtime error
Commit
β’
ff1f490
1
Parent(s):
94e40f7
Upload folder using huggingface_hub
Browse files- README.md +1 -1
- __pycache__/app.cpython-39.pyc +0 -0
- app.py +1 -1
- src/README.md +1 -122
- src/demo/app.py +1 -1
- src/pyproject.toml +3 -3
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
---
|
3 |
tags: [gradio-custom-component,gradio-template-Fallback,time,calendar,forms]
|
4 |
title: gradio_calendar V0.0.2
|
5 |
-
colorFrom:
|
6 |
colorTo: red
|
7 |
sdk: docker
|
8 |
pinned: false
|
|
|
2 |
---
|
3 |
tags: [gradio-custom-component,gradio-template-Fallback,time,calendar,forms]
|
4 |
title: gradio_calendar V0.0.2
|
5 |
+
colorFrom: blue
|
6 |
colorTo: red
|
7 |
sdk: docker
|
8 |
pinned: false
|
__pycache__/app.cpython-39.pyc
ADDED
Binary file (683 Bytes). View file
|
|
app.py
CHANGED
@@ -21,7 +21,7 @@ with gr.Blocks(
|
|
21 |
# `gradio_calendar`
|
22 |
|
23 |
<div style="display: flex; gap: 7px;">
|
24 |
-
<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/
|
25 |
</div>
|
26 |
|
27 |
Gradio component for selecting dates with a calendar π
|
|
|
21 |
# `gradio_calendar`
|
22 |
|
23 |
<div style="display: flex; gap: 7px;">
|
24 |
+
<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>
|
25 |
</div>
|
26 |
|
27 |
Gradio component for selecting dates with a calendar π
|
src/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
|
2 |
# `gradio_calendar`
|
3 |
-
<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/
|
4 |
|
5 |
Gradio component for selecting dates with a calendar π
|
6 |
|
@@ -12,46 +12,6 @@ pip install gradio_calendar
|
|
12 |
|
13 |
## Usage
|
14 |
|
15 |
-
```python
|
16 |
-
|
17 |
-
import gradio as gr
|
18 |
-
from _app import demo as app
|
19 |
-
import os
|
20 |
-
|
21 |
-
_docs = {'Calendar': {'description': 'A calendar component that allows users to select a date.\n\ndepending on the value of the type parameter.\n\n\n value: The default date value, formatted as YYYY-MM-DD. Can be either a string or datetime.datetime object.\n type: The type of the value to pass to the python function. Either "string" or "datetime".\n label: The label for the component.\n info: Extra text to render below the component.\n show_label: Whether to show the label for the component.\n container: Whether to show the component in a container.\n scale: The relative size of the component compared to other components in the same row.\n min_width: The minimum width of the component.\n interactive: Whether to allow the user to interact with the component.\n visible: Whether to show the component.\n elem_id: The id of the component. Useful for custom js or css.\n elem_classes: The classes of the component. Useful for custom js or css.\n render: Whether to render the component in the parent Blocks scope.\n load_fn: A function to run when the component is first loaded onto the page to set the intial value.\n every: Whether load_fn should be run on a fixed time interval.', 'members': {'__init__': {'value': {'type': 'str | datetime.datetime', 'default': 'None', 'description': None}, 'type': {'type': 'Literal["string", "datetime"]', 'default': '"datetime"', 'description': None}, 'label': {'type': 'str | None', 'default': 'None', 'description': None}, 'info': {'type': 'str | None', 'default': 'None', 'description': None}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': None}, 'container': {'type': 'bool', 'default': 'True', 'description': None}, 'scale': {'type': 'int | None', 'default': 'None', 'description': None}, 'min_width': {'type': 'int | None', 'default': 'None', 'description': None}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': None}, 'visible': {'type': 'bool', 'default': 'True', 'description': None}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': None}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': None}, 'render': {'type': 'bool', 'default': 'True', 'description': None}, 'load_fn': {'type': 'Callable[..., Any] | None', 'default': 'None', 'description': None}, 'every': {'type': 'float | None', 'default': 'None', 'description': None}}, 'postprocess': {'value': {'type': 'str | datetime.datetime | None', 'description': None}}, 'preprocess': {'return': {'type': 'str | datetime.datetime | None', 'description': None}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': ''}, 'input': {'type': None, 'default': None, 'description': ''}, 'submit': {'type': None, 'default': None, 'description': ''}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'Calendar': []}}}
|
22 |
-
|
23 |
-
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
24 |
-
|
25 |
-
with gr.Blocks(
|
26 |
-
css=abs_path,
|
27 |
-
theme=gr.themes.Default(
|
28 |
-
font_mono=[
|
29 |
-
gr.themes.GoogleFont("Inconsolata"),
|
30 |
-
"monospace",
|
31 |
-
],
|
32 |
-
),
|
33 |
-
) as demo:
|
34 |
-
gr.Markdown(
|
35 |
-
"""
|
36 |
-
# `gradio_calendar`
|
37 |
-
|
38 |
-
<div style="display: flex; gap: 7px;">
|
39 |
-
<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/settings/discussions" target="_blank"><img alt="Static Badge" src="https://img.shields.io/badge/%F0%9F%A4%97%20Discuss-%23097EFF?style=flat&logoColor=black"></a>
|
40 |
-
</div>
|
41 |
-
|
42 |
-
Gradio component for selecting dates with a calendar π
|
43 |
-
""", elem_classes=["md-custom"], header_links=True)
|
44 |
-
app.render()
|
45 |
-
gr.Markdown(
|
46 |
-
"""
|
47 |
-
## Installation
|
48 |
-
|
49 |
-
```bash
|
50 |
-
pip install gradio_calendar
|
51 |
-
```
|
52 |
-
|
53 |
-
## Usage
|
54 |
-
|
55 |
```python
|
56 |
import gradio as gr
|
57 |
from gradio_calendar import Calendar
|
@@ -70,87 +30,6 @@ demo = gr.Interface(is_weekday,
|
|
70 |
if __name__ == "__main__":
|
71 |
demo.launch()
|
72 |
|
73 |
-
```
|
74 |
-
""", elem_classes=["md-custom"], header_links=True)
|
75 |
-
|
76 |
-
|
77 |
-
gr.Markdown("""
|
78 |
-
## `Calendar`
|
79 |
-
|
80 |
-
### Initialization
|
81 |
-
""", elem_classes=["md-custom"], header_links=True)
|
82 |
-
|
83 |
-
gr.ParamViewer(value=_docs["Calendar"]["members"]["__init__"], linkify=[])
|
84 |
-
|
85 |
-
|
86 |
-
gr.Markdown("### Events")
|
87 |
-
gr.ParamViewer(value=_docs["Calendar"]["events"], linkify=['Event'])
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
gr.Markdown("""
|
93 |
-
|
94 |
-
### User function
|
95 |
-
|
96 |
-
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).
|
97 |
-
|
98 |
-
- When used as an Input, the component only impacts the input signature of the user function.
|
99 |
-
- When used as an output, the component only impacts the return signature of the user function.
|
100 |
-
|
101 |
-
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
```python
|
106 |
-
def predict(
|
107 |
-
value: str | datetime.datetime | None
|
108 |
-
) -> str | datetime.datetime | None:
|
109 |
-
return value
|
110 |
-
```
|
111 |
-
""", elem_classes=["md-custom", "Calendar-user-fn"], header_links=True)
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
demo.load(None, js=r"""function() {
|
117 |
-
const refs = {};
|
118 |
-
const user_fn_refs = {
|
119 |
-
Calendar: [], };
|
120 |
-
requestAnimationFrame(() => {
|
121 |
-
|
122 |
-
Object.entries(user_fn_refs).forEach(([key, refs]) => {
|
123 |
-
if (refs.length > 0) {
|
124 |
-
const el = document.querySelector(`.${key}-user-fn`);
|
125 |
-
if (!el) return;
|
126 |
-
refs.forEach(ref => {
|
127 |
-
el.innerHTML = el.innerHTML.replace(
|
128 |
-
new RegExp("\\b"+ref+"\\b", "g"),
|
129 |
-
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
130 |
-
);
|
131 |
-
})
|
132 |
-
}
|
133 |
-
})
|
134 |
-
|
135 |
-
Object.entries(refs).forEach(([key, refs]) => {
|
136 |
-
if (refs.length > 0) {
|
137 |
-
const el = document.querySelector(`.${key}`);
|
138 |
-
if (!el) return;
|
139 |
-
refs.forEach(ref => {
|
140 |
-
el.innerHTML = el.innerHTML.replace(
|
141 |
-
new RegExp("\\b"+ref+"\\b", "g"),
|
142 |
-
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
143 |
-
);
|
144 |
-
})
|
145 |
-
}
|
146 |
-
})
|
147 |
-
})
|
148 |
-
}
|
149 |
-
|
150 |
-
""")
|
151 |
-
|
152 |
-
demo.launch()
|
153 |
-
|
154 |
```
|
155 |
|
156 |
## `Calendar`
|
|
|
1 |
|
2 |
# `gradio_calendar`
|
3 |
+
<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>
|
4 |
|
5 |
Gradio component for selecting dates with a calendar π
|
6 |
|
|
|
12 |
|
13 |
## Usage
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
```python
|
16 |
import gradio as gr
|
17 |
from gradio_calendar import Calendar
|
|
|
30 |
if __name__ == "__main__":
|
31 |
demo.launch()
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
```
|
34 |
|
35 |
## `Calendar`
|
src/demo/app.py
CHANGED
@@ -21,7 +21,7 @@ with gr.Blocks(
|
|
21 |
# `gradio_calendar`
|
22 |
|
23 |
<div style="display: flex; gap: 7px;">
|
24 |
-
<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/
|
25 |
</div>
|
26 |
|
27 |
Gradio component for selecting dates with a calendar π
|
|
|
21 |
# `gradio_calendar`
|
22 |
|
23 |
<div style="display: flex; gap: 7px;">
|
24 |
+
<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>
|
25 |
</div>
|
26 |
|
27 |
Gradio component for selecting dates with a calendar π
|
src/pyproject.toml
CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
8 |
|
9 |
[project]
|
10 |
name = "gradio_calendar"
|
11 |
-
version = "0.0.
|
12 |
description = "Gradio component for selecting dates with a calendar π"
|
13 |
readme = "README.md"
|
14 |
license = "MIT"
|
@@ -37,10 +37,10 @@ dev = ["build", "twine"]
|
|
37 |
|
38 |
[project.urls]
|
39 |
repository = "https://github.com/freddyaboulton/gradio-calendar"
|
40 |
-
space = "https://huggingface.co/spaces/freddyaboulton/gradio_calendar
|
41 |
|
42 |
[tool.hatch.build]
|
43 |
-
artifacts = ["/backend/gradio_calendar/templates", "*.pyi", "backend/gradio_calendar/templates", "backend/gradio_calendar/templates", "backend/gradio_calendar/templates", "backend/gradio_calendar/templates"
|
44 |
|
45 |
[tool.hatch.build.targets.wheel]
|
46 |
packages = ["/backend/gradio_calendar"]
|
|
|
8 |
|
9 |
[project]
|
10 |
name = "gradio_calendar"
|
11 |
+
version = "0.0.4"
|
12 |
description = "Gradio component for selecting dates with a calendar π"
|
13 |
readme = "README.md"
|
14 |
license = "MIT"
|
|
|
37 |
|
38 |
[project.urls]
|
39 |
repository = "https://github.com/freddyaboulton/gradio-calendar"
|
40 |
+
space = "https://huggingface.co/spaces/freddyaboulton/gradio_calendar"
|
41 |
|
42 |
[tool.hatch.build]
|
43 |
+
artifacts = ["/backend/gradio_calendar/templates", "*.pyi", "backend/gradio_calendar/templates", "backend/gradio_calendar/templates", "backend/gradio_calendar/templates", "backend/gradio_calendar/templates"]
|
44 |
|
45 |
[tool.hatch.build.targets.wheel]
|
46 |
packages = ["/backend/gradio_calendar"]
|