semvec/pypi-packages huggingface dataset:
argmax-gradio-components 0.1.0
Argmax Custom Components for Gradio
Requires Python: >=3.9

---
tags: [gradio-custom-component, Slider]
title: argmax_gradio_components
short_description: Custom components for Gradio
colorFrom: blue
colorTo: yellow
sdk: gradio
pinned: false
app_file: space.py
---

# `argmax_gradio_components`

🧩 Custom Gradio components by Argmax, Inc.

## Components

- [RangeSlider](#rangeslider): Double-thumb slider component for precise interval selection within a certain range.

## Installation

```bash
pip install argmax_gradio_components
```

## RangeSlider
![](static/rangeslider.gif)
### Usage
```python
import gradio as gr
from argmax_gradio_components import RangeSlider

with gr.Blocks() as demo:
    range_slider = RangeSlider(minimum=0, maximum=100, label="Select Range")
    output = gr.Markdown("Selected range: {0} to {1}")
    
    range_slider.change(
        lambda x: f"Selected range: {x[0]} to {x[1]}",
        inputs=range_slider,
        outputs=output
    )

demo.launch()
```

### Component Details
### 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>minimum</code></td>
<td align="left" style="width: 25%;">

```python
float
```

</td>
<td align="left"><code>0</code></td>
<td align="left">Minimum value for slider.</td>
</tr>

<tr>
<td align="left"><code>maximum</code></td>
<td align="left" style="width: 25%;">

```python
float
```

</td>
<td align="left"><code>100</code></td>
<td align="left">Maximum value for slider.</td>
</tr>

<tr>
<td align="left"><code>value</code></td>
<td align="left" style="width: 25%;">

```python
tuple[float, float] | Callable | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">Default value. If callable, the function will be called whenever the app loads to set the initial value of the component. </td>
</tr>

<tr>
<td align="left"><code>step</code></td>
<td align="left" style="width: 25%;">

```python
float | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">Increment between slider values.</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">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.</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">If False, component will be hidden.</td>
</tr>
</table>

### Events
| name | description |
|:-----|:------------|
| `change` | Triggered when the value of the RangeSlider changes either because of user input OR because of a function update. |
| `input` | This listener is triggered when the user changes the value of the RangeSlider. |
| `release` | This listener is triggered when the user releases the mouse on this RangeSlider. |
ownershipworkaround 0.1.0
Only one object containing the iterator or closure, cloning and errors related to this concept
Requires Python: >=3.12

# Motivation

In my plabic package (https://pypi.org/project/plabic/), I had a class which had a private iterator in my implementation of shuffle algebra calculations

But then if I did the shuffle product of x and x, those iterators would be both driven together rather than separately
Simlarly if I did x and y, then used y somehere else, the x iterator which should have had all of x and y information
would be missing some pieces depending on how the y iterator had been driven.

# Errors

So we have errors that cover this kind of situation. The first being SameObjectError and the latter being ConsumedObjectError

# Cloning

Suppose we provide a way of cloning the objects so that the closures/iterators contained are separate now. Then the two functions
avoid_common_pointers and avoid_this_pointer can fix up the argument lists to that combining function which expects all distinct objects.
If there are no repeats, it does not do anything and does not even need to ever try to call that optional cloning function.
If there are repeats, it will call the cloning function appropriately giving the new list of arguments.

# Decorators

Assumes that the function being called has all of it's args as that same type T
and none of the kwargs have T in them that need cloning

## handle_args_repeats

if you provide the cloner function on T and it will call that cloner on any repeated arguments in args
if you don't provide the cloner and there are repeats will raise the SameObjectError
if you don't provide the cloner and there are no repeats, there will not be an error

## invalidate_these_args

Either provide
- a list of argument numbers that become invalid after this function
- a list of argument numbers that remain valid after this function with the rest becoming invalid

Also need the function which does the invalidation and a way to query the validity

This makes sure all of the args are valid and then calls the function assuming that was the case
After this, the args which are supposed to become invalid are invalidated