Commit
β’
daca7b6
1
Parent(s):
eae39e4
Upload folder using huggingface_hub
Browse files- .gitignore +12 -0
- README.md +295 -6
- __init__.py +0 -0
- app.py +27 -0
- docs.md +290 -0
- requirements.txt +1 -0
.gitignore
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.eggs/
|
2 |
+
dist/
|
3 |
+
*.pyc
|
4 |
+
__pycache__/
|
5 |
+
*.py[cod]
|
6 |
+
*$py.class
|
7 |
+
__tmp/*
|
8 |
+
*.pyi
|
9 |
+
.mypycache
|
10 |
+
.ruff_cache
|
11 |
+
node_modules
|
12 |
+
backend/**/templates/
|
README.md
CHANGED
@@ -1,12 +1,301 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.29.0
|
8 |
-
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
tags: [gradio-custom-component, Slider, leaderboards, forms, filtering, slider]
|
3 |
+
title: gradio_rangeslider
|
4 |
+
short_description: π Slider component for selecting a range of values
|
5 |
+
colorFrom: blue
|
6 |
colorTo: yellow
|
7 |
sdk: gradio
|
|
|
|
|
8 |
pinned: false
|
9 |
+
app_file: app.py
|
10 |
---
|
11 |
|
12 |
+
# `gradio_rangeslider`
|
13 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
|
14 |
+
|
15 |
+
π Slider component for selecting a range of values.
|
16 |
+
|
17 |
+
## Installation
|
18 |
+
|
19 |
+
```bash
|
20 |
+
pip install gradio_rangeslider
|
21 |
+
```
|
22 |
+
|
23 |
+
## Usage
|
24 |
+
|
25 |
+
The `RangeSlider` functions similarly to the core Gradio `Slider` except that it shows two draggable thumbtracks. The `value` of the component is a tuple of the two endpoints of the range.
|
26 |
+
|
27 |
+
```python
|
28 |
+
|
29 |
+
import gradio as gr
|
30 |
+
from gradio_rangeslider import RangeSlider
|
31 |
+
|
32 |
+
text = "## The range is: {min} to {max}"
|
33 |
+
|
34 |
+
with gr.Blocks() as demo:
|
35 |
+
gr.Markdown("""## π RangeSlider
|
36 |
+
Drag either end and see the selected endpoints update in real-time.
|
37 |
+
""")
|
38 |
+
range_slider = RangeSlider(minimum=0, maximum=100, value=(0, 100))
|
39 |
+
range_ = gr.Markdown(value=text.format(min=0, max=100))
|
40 |
+
range_slider.change(lambda s: text.format(min=s[0], max=s[1]), range_slider, range_,
|
41 |
+
show_progress="hide")
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
demo.launch()
|
47 |
+
|
48 |
+
```
|
49 |
+
|
50 |
+
## `RangeSlider`
|
51 |
+
|
52 |
+
### Initialization
|
53 |
+
|
54 |
+
<table>
|
55 |
+
<thead>
|
56 |
+
<tr>
|
57 |
+
<th align="left">name</th>
|
58 |
+
<th align="left" style="width: 25%;">type</th>
|
59 |
+
<th align="left">default</th>
|
60 |
+
<th align="left">description</th>
|
61 |
+
</tr>
|
62 |
+
</thead>
|
63 |
+
<tbody>
|
64 |
+
<tr>
|
65 |
+
<td align="left"><code>minimum</code></td>
|
66 |
+
<td align="left" style="width: 25%;">
|
67 |
+
|
68 |
+
```python
|
69 |
+
float
|
70 |
+
```
|
71 |
+
|
72 |
+
</td>
|
73 |
+
<td align="left"><code>0</code></td>
|
74 |
+
<td align="left">minimum value for slider.</td>
|
75 |
+
</tr>
|
76 |
+
|
77 |
+
<tr>
|
78 |
+
<td align="left"><code>maximum</code></td>
|
79 |
+
<td align="left" style="width: 25%;">
|
80 |
+
|
81 |
+
```python
|
82 |
+
float
|
83 |
+
```
|
84 |
+
|
85 |
+
</td>
|
86 |
+
<td align="left"><code>100</code></td>
|
87 |
+
<td align="left">maximum value for slider.</td>
|
88 |
+
</tr>
|
89 |
+
|
90 |
+
<tr>
|
91 |
+
<td align="left"><code>value</code></td>
|
92 |
+
<td align="left" style="width: 25%;">
|
93 |
+
|
94 |
+
```python
|
95 |
+
tuple[float, float] | Callable | None
|
96 |
+
```
|
97 |
+
|
98 |
+
</td>
|
99 |
+
<td align="left"><code>None</code></td>
|
100 |
+
<td align="left">default value. If callable, the function will be called whenever the app loads to set the initial value of the component. Ignored if randomized=True.</td>
|
101 |
+
</tr>
|
102 |
+
|
103 |
+
<tr>
|
104 |
+
<td align="left"><code>step</code></td>
|
105 |
+
<td align="left" style="width: 25%;">
|
106 |
+
|
107 |
+
```python
|
108 |
+
float | None
|
109 |
+
```
|
110 |
+
|
111 |
+
</td>
|
112 |
+
<td align="left"><code>None</code></td>
|
113 |
+
<td align="left">increment between slider values.</td>
|
114 |
+
</tr>
|
115 |
+
|
116 |
+
<tr>
|
117 |
+
<td align="left"><code>label</code></td>
|
118 |
+
<td align="left" style="width: 25%;">
|
119 |
+
|
120 |
+
```python
|
121 |
+
str | None
|
122 |
+
```
|
123 |
+
|
124 |
+
</td>
|
125 |
+
<td align="left"><code>None</code></td>
|
126 |
+
<td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
|
127 |
+
</tr>
|
128 |
+
|
129 |
+
<tr>
|
130 |
+
<td align="left"><code>info</code></td>
|
131 |
+
<td align="left" style="width: 25%;">
|
132 |
+
|
133 |
+
```python
|
134 |
+
str | None
|
135 |
+
```
|
136 |
+
|
137 |
+
</td>
|
138 |
+
<td align="left"><code>None</code></td>
|
139 |
+
<td align="left">additional component description.</td>
|
140 |
+
</tr>
|
141 |
+
|
142 |
+
<tr>
|
143 |
+
<td align="left"><code>every</code></td>
|
144 |
+
<td align="left" style="width: 25%;">
|
145 |
+
|
146 |
+
```python
|
147 |
+
float | None
|
148 |
+
```
|
149 |
+
|
150 |
+
</td>
|
151 |
+
<td align="left"><code>None</code></td>
|
152 |
+
<td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
|
153 |
+
</tr>
|
154 |
+
|
155 |
+
<tr>
|
156 |
+
<td align="left"><code>show_label</code></td>
|
157 |
+
<td align="left" style="width: 25%;">
|
158 |
+
|
159 |
+
```python
|
160 |
+
bool | None
|
161 |
+
```
|
162 |
+
|
163 |
+
</td>
|
164 |
+
<td align="left"><code>None</code></td>
|
165 |
+
<td align="left">if True, will display label.</td>
|
166 |
+
</tr>
|
167 |
+
|
168 |
+
<tr>
|
169 |
+
<td align="left"><code>container</code></td>
|
170 |
+
<td align="left" style="width: 25%;">
|
171 |
+
|
172 |
+
```python
|
173 |
+
bool
|
174 |
+
```
|
175 |
+
|
176 |
+
</td>
|
177 |
+
<td align="left"><code>True</code></td>
|
178 |
+
<td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
|
179 |
+
</tr>
|
180 |
+
|
181 |
+
<tr>
|
182 |
+
<td align="left"><code>scale</code></td>
|
183 |
+
<td align="left" style="width: 25%;">
|
184 |
+
|
185 |
+
```python
|
186 |
+
int | None
|
187 |
+
```
|
188 |
+
|
189 |
+
</td>
|
190 |
+
<td align="left"><code>None</code></td>
|
191 |
+
<td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
|
192 |
+
</tr>
|
193 |
+
|
194 |
+
<tr>
|
195 |
+
<td align="left"><code>min_width</code></td>
|
196 |
+
<td align="left" style="width: 25%;">
|
197 |
+
|
198 |
+
```python
|
199 |
+
int
|
200 |
+
```
|
201 |
+
|
202 |
+
</td>
|
203 |
+
<td align="left"><code>160</code></td>
|
204 |
+
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
|
205 |
+
</tr>
|
206 |
+
|
207 |
+
<tr>
|
208 |
+
<td align="left"><code>interactive</code></td>
|
209 |
+
<td align="left" style="width: 25%;">
|
210 |
+
|
211 |
+
```python
|
212 |
+
bool | None
|
213 |
+
```
|
214 |
+
|
215 |
+
</td>
|
216 |
+
<td align="left"><code>None</code></td>
|
217 |
+
<td align="left">if True, slider will be adjustable; if False, adjusting will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>
|
218 |
+
</tr>
|
219 |
+
|
220 |
+
<tr>
|
221 |
+
<td align="left"><code>visible</code></td>
|
222 |
+
<td align="left" style="width: 25%;">
|
223 |
+
|
224 |
+
```python
|
225 |
+
bool
|
226 |
+
```
|
227 |
+
|
228 |
+
</td>
|
229 |
+
<td align="left"><code>True</code></td>
|
230 |
+
<td align="left">If False, component will be hidden.</td>
|
231 |
+
</tr>
|
232 |
+
|
233 |
+
<tr>
|
234 |
+
<td align="left"><code>elem_id</code></td>
|
235 |
+
<td align="left" style="width: 25%;">
|
236 |
+
|
237 |
+
```python
|
238 |
+
str | None
|
239 |
+
```
|
240 |
+
|
241 |
+
</td>
|
242 |
+
<td align="left"><code>None</code></td>
|
243 |
+
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
244 |
+
</tr>
|
245 |
+
|
246 |
+
<tr>
|
247 |
+
<td align="left"><code>elem_classes</code></td>
|
248 |
+
<td align="left" style="width: 25%;">
|
249 |
+
|
250 |
+
```python
|
251 |
+
list[str] | str | None
|
252 |
+
```
|
253 |
+
|
254 |
+
</td>
|
255 |
+
<td align="left"><code>None</code></td>
|
256 |
+
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
257 |
+
</tr>
|
258 |
+
|
259 |
+
<tr>
|
260 |
+
<td align="left"><code>render</code></td>
|
261 |
+
<td align="left" style="width: 25%;">
|
262 |
+
|
263 |
+
```python
|
264 |
+
bool
|
265 |
+
```
|
266 |
+
|
267 |
+
</td>
|
268 |
+
<td align="left"><code>True</code></td>
|
269 |
+
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
|
270 |
+
</tr>
|
271 |
+
</tbody></table>
|
272 |
+
|
273 |
+
|
274 |
+
### Events
|
275 |
+
|
276 |
+
| name | description |
|
277 |
+
|:-----|:------------|
|
278 |
+
| `change` | Triggered when the value of the RangeSlider changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
|
279 |
+
| `input` | This listener is triggered when the user changes the value of the RangeSlider. |
|
280 |
+
|
281 |
+
|
282 |
+
|
283 |
+
### User function
|
284 |
+
|
285 |
+
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).
|
286 |
+
|
287 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
288 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
289 |
+
|
290 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
291 |
+
|
292 |
+
- **As output:** Is passed, passes slider value as a {float} into the function.
|
293 |
+
- **As input:** Should return, expects an {int} or {float} returned from function and sets slider value to it as long as it is within range (otherwise, sets to minimum value).
|
294 |
+
|
295 |
+
```python
|
296 |
+
def predict(
|
297 |
+
value: tuple[float, float]
|
298 |
+
) -> tuple[float, float] | None:
|
299 |
+
return value
|
300 |
+
```
|
301 |
+
|
__init__.py
ADDED
File without changes
|
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_rangeslider import RangeSlider
|
4 |
+
from pathlib import Path
|
5 |
+
|
6 |
+
text = "## The range is: {min} to {max}"
|
7 |
+
|
8 |
+
docs = Path(__file__).parent / "docs.md"
|
9 |
+
|
10 |
+
with gr.Blocks() as demo:
|
11 |
+
with gr.Tabs():
|
12 |
+
with gr.Tab("Demo"):
|
13 |
+
gr.Markdown("""## π RangeSlider
|
14 |
+
|
15 |
+
## Drag either end and see the selected endpoints update in real-time.
|
16 |
+
""")
|
17 |
+
range_slider = RangeSlider(minimum=0, maximum=100, value=(0, 100))
|
18 |
+
range_ = gr.Markdown(value=text.format(min=0, max=100))
|
19 |
+
range_slider.change(lambda s: text.format(min=s[0], max=s[1]), range_slider, range_,
|
20 |
+
show_progress="hide", trigger_mode="always_last")
|
21 |
+
gr.Examples([(20, 30), (40, 80)], inputs=[range_slider])
|
22 |
+
with gr.Tab("Docs"):
|
23 |
+
gr.Markdown(docs.read_text())
|
24 |
+
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
demo.launch()
|
docs.md
ADDED
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# `gradio_rangeslider`
|
2 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
|
3 |
+
|
4 |
+
π Slider component for selecting a range of values
|
5 |
+
|
6 |
+
## Installation
|
7 |
+
|
8 |
+
```bash
|
9 |
+
pip install gradio_rangeslider
|
10 |
+
```
|
11 |
+
|
12 |
+
## Usage
|
13 |
+
|
14 |
+
The `RangeSlider` functions similarly to the core Gradio `Slider` except that it shows two draggable thumbtracks. The `value` of the component is a tuple of the two endpoints of the range.
|
15 |
+
|
16 |
+
```python
|
17 |
+
|
18 |
+
import gradio as gr
|
19 |
+
from gradio_rangeslider import RangeSlider
|
20 |
+
|
21 |
+
text = "## The range is: {min} to {max}"
|
22 |
+
|
23 |
+
with gr.Blocks() as demo:
|
24 |
+
gr.Markdown("""## π RangeSlider
|
25 |
+
Drag either end and see the selected endpoints update in real-time.
|
26 |
+
""")
|
27 |
+
range_slider = RangeSlider(minimum=0, maximum=100, value=(0, 100))
|
28 |
+
range_ = gr.Markdown(value=text.format(min=0, max=100))
|
29 |
+
range_slider.change(lambda s: text.format(min=s[0], max=s[1]), range_slider, range_,
|
30 |
+
show_progress="hide")
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
if __name__ == "__main__":
|
35 |
+
demo.launch()
|
36 |
+
|
37 |
+
```
|
38 |
+
|
39 |
+
## `RangeSlider`
|
40 |
+
|
41 |
+
### Initialization
|
42 |
+
|
43 |
+
<table>
|
44 |
+
<thead>
|
45 |
+
<tr>
|
46 |
+
<th align="left">name</th>
|
47 |
+
<th align="left" style="width: 25%;">type</th>
|
48 |
+
<th align="left">default</th>
|
49 |
+
<th align="left">description</th>
|
50 |
+
</tr>
|
51 |
+
</thead>
|
52 |
+
<tbody>
|
53 |
+
<tr>
|
54 |
+
<td align="left"><code>minimum</code></td>
|
55 |
+
<td align="left" style="width: 25%;">
|
56 |
+
|
57 |
+
```python
|
58 |
+
float
|
59 |
+
```
|
60 |
+
|
61 |
+
</td>
|
62 |
+
<td align="left"><code>0</code></td>
|
63 |
+
<td align="left">minimum value for slider.</td>
|
64 |
+
</tr>
|
65 |
+
|
66 |
+
<tr>
|
67 |
+
<td align="left"><code>maximum</code></td>
|
68 |
+
<td align="left" style="width: 25%;">
|
69 |
+
|
70 |
+
```python
|
71 |
+
float
|
72 |
+
```
|
73 |
+
|
74 |
+
</td>
|
75 |
+
<td align="left"><code>100</code></td>
|
76 |
+
<td align="left">maximum value for slider.</td>
|
77 |
+
</tr>
|
78 |
+
|
79 |
+
<tr>
|
80 |
+
<td align="left"><code>value</code></td>
|
81 |
+
<td align="left" style="width: 25%;">
|
82 |
+
|
83 |
+
```python
|
84 |
+
tuple[float, float] | Callable | None
|
85 |
+
```
|
86 |
+
|
87 |
+
</td>
|
88 |
+
<td align="left"><code>None</code></td>
|
89 |
+
<td align="left">default value. If callable, the function will be called whenever the app loads to set the initial value of the component. Ignored if randomized=True.</td>
|
90 |
+
</tr>
|
91 |
+
|
92 |
+
<tr>
|
93 |
+
<td align="left"><code>step</code></td>
|
94 |
+
<td align="left" style="width: 25%;">
|
95 |
+
|
96 |
+
```python
|
97 |
+
float | None
|
98 |
+
```
|
99 |
+
|
100 |
+
</td>
|
101 |
+
<td align="left"><code>None</code></td>
|
102 |
+
<td align="left">increment between slider values.</td>
|
103 |
+
</tr>
|
104 |
+
|
105 |
+
<tr>
|
106 |
+
<td align="left"><code>label</code></td>
|
107 |
+
<td align="left" style="width: 25%;">
|
108 |
+
|
109 |
+
```python
|
110 |
+
str | None
|
111 |
+
```
|
112 |
+
|
113 |
+
</td>
|
114 |
+
<td align="left"><code>None</code></td>
|
115 |
+
<td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
|
116 |
+
</tr>
|
117 |
+
|
118 |
+
<tr>
|
119 |
+
<td align="left"><code>info</code></td>
|
120 |
+
<td align="left" style="width: 25%;">
|
121 |
+
|
122 |
+
```python
|
123 |
+
str | None
|
124 |
+
```
|
125 |
+
|
126 |
+
</td>
|
127 |
+
<td align="left"><code>None</code></td>
|
128 |
+
<td align="left">additional component description.</td>
|
129 |
+
</tr>
|
130 |
+
|
131 |
+
<tr>
|
132 |
+
<td align="left"><code>every</code></td>
|
133 |
+
<td align="left" style="width: 25%;">
|
134 |
+
|
135 |
+
```python
|
136 |
+
float | None
|
137 |
+
```
|
138 |
+
|
139 |
+
</td>
|
140 |
+
<td align="left"><code>None</code></td>
|
141 |
+
<td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
|
142 |
+
</tr>
|
143 |
+
|
144 |
+
<tr>
|
145 |
+
<td align="left"><code>show_label</code></td>
|
146 |
+
<td align="left" style="width: 25%;">
|
147 |
+
|
148 |
+
```python
|
149 |
+
bool | None
|
150 |
+
```
|
151 |
+
|
152 |
+
</td>
|
153 |
+
<td align="left"><code>None</code></td>
|
154 |
+
<td align="left">if True, will display label.</td>
|
155 |
+
</tr>
|
156 |
+
|
157 |
+
<tr>
|
158 |
+
<td align="left"><code>container</code></td>
|
159 |
+
<td align="left" style="width: 25%;">
|
160 |
+
|
161 |
+
```python
|
162 |
+
bool
|
163 |
+
```
|
164 |
+
|
165 |
+
</td>
|
166 |
+
<td align="left"><code>True</code></td>
|
167 |
+
<td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
|
168 |
+
</tr>
|
169 |
+
|
170 |
+
<tr>
|
171 |
+
<td align="left"><code>scale</code></td>
|
172 |
+
<td align="left" style="width: 25%;">
|
173 |
+
|
174 |
+
```python
|
175 |
+
int | None
|
176 |
+
```
|
177 |
+
|
178 |
+
</td>
|
179 |
+
<td align="left"><code>None</code></td>
|
180 |
+
<td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
|
181 |
+
</tr>
|
182 |
+
|
183 |
+
<tr>
|
184 |
+
<td align="left"><code>min_width</code></td>
|
185 |
+
<td align="left" style="width: 25%;">
|
186 |
+
|
187 |
+
```python
|
188 |
+
int
|
189 |
+
```
|
190 |
+
|
191 |
+
</td>
|
192 |
+
<td align="left"><code>160</code></td>
|
193 |
+
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
|
194 |
+
</tr>
|
195 |
+
|
196 |
+
<tr>
|
197 |
+
<td align="left"><code>interactive</code></td>
|
198 |
+
<td align="left" style="width: 25%;">
|
199 |
+
|
200 |
+
```python
|
201 |
+
bool | None
|
202 |
+
```
|
203 |
+
|
204 |
+
</td>
|
205 |
+
<td align="left"><code>None</code></td>
|
206 |
+
<td align="left">if True, slider will be adjustable; if False, adjusting will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>
|
207 |
+
</tr>
|
208 |
+
|
209 |
+
<tr>
|
210 |
+
<td align="left"><code>visible</code></td>
|
211 |
+
<td align="left" style="width: 25%;">
|
212 |
+
|
213 |
+
```python
|
214 |
+
bool
|
215 |
+
```
|
216 |
+
|
217 |
+
</td>
|
218 |
+
<td align="left"><code>True</code></td>
|
219 |
+
<td align="left">If False, component will be hidden.</td>
|
220 |
+
</tr>
|
221 |
+
|
222 |
+
<tr>
|
223 |
+
<td align="left"><code>elem_id</code></td>
|
224 |
+
<td align="left" style="width: 25%;">
|
225 |
+
|
226 |
+
```python
|
227 |
+
str | None
|
228 |
+
```
|
229 |
+
|
230 |
+
</td>
|
231 |
+
<td align="left"><code>None</code></td>
|
232 |
+
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
233 |
+
</tr>
|
234 |
+
|
235 |
+
<tr>
|
236 |
+
<td align="left"><code>elem_classes</code></td>
|
237 |
+
<td align="left" style="width: 25%;">
|
238 |
+
|
239 |
+
```python
|
240 |
+
list[str] | str | None
|
241 |
+
```
|
242 |
+
|
243 |
+
</td>
|
244 |
+
<td align="left"><code>None</code></td>
|
245 |
+
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
246 |
+
</tr>
|
247 |
+
|
248 |
+
<tr>
|
249 |
+
<td align="left"><code>render</code></td>
|
250 |
+
<td align="left" style="width: 25%;">
|
251 |
+
|
252 |
+
```python
|
253 |
+
bool
|
254 |
+
```
|
255 |
+
|
256 |
+
</td>
|
257 |
+
<td align="left"><code>True</code></td>
|
258 |
+
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
|
259 |
+
</tr>
|
260 |
+
</tbody></table>
|
261 |
+
|
262 |
+
|
263 |
+
### Events
|
264 |
+
|
265 |
+
| name | description |
|
266 |
+
|:-----|:------------|
|
267 |
+
| `change` | Triggered when the value of the RangeSlider changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
|
268 |
+
| `input` | This listener is triggered when the user changes the value of the RangeSlider. |
|
269 |
+
|
270 |
+
|
271 |
+
|
272 |
+
### User function
|
273 |
+
|
274 |
+
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).
|
275 |
+
|
276 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
277 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
278 |
+
|
279 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
280 |
+
|
281 |
+
- **As output:** Is passed, passes slider value as a {float} into the function.
|
282 |
+
- **As input:** Should return, expects an {int} or {float} returned from function and sets slider value to it as long as it is within range (otherwise, sets to minimum value).
|
283 |
+
|
284 |
+
```python
|
285 |
+
def predict(
|
286 |
+
value: tuple[float, float]
|
287 |
+
) -> tuple[float, float] | None:
|
288 |
+
return value
|
289 |
+
```
|
290 |
+
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio_rangeslider
|