gradio-sandboxcomponent


Namegradio-sandboxcomponent JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryGradio library for easily interacting with remote sandbox.
upload_time2025-01-14 13:03:36
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords gradio-custom-component gradio-template-simpletextbox
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# `gradio_sandboxcomponent`
<a href="https://pypi.org/project/gradio_sandboxcomponent/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_sandboxcomponent"></a>  

Gradio library for easily interacting with remote sandbox.

## Installation

```bash
pip install gradio_sandboxcomponent
```

## Usage

```python

from typing import Any
import gradio as gr
from gradio_sandboxcomponent import SandboxComponent

example = SandboxComponent().example_value()


with gr.Blocks() as demo:
    with gr.Tab("Sandbox Demo"):
        with gr.Row():
            gr.Markdown("## Sandbox")
        with gr.Row():
            sandboxUrl = gr.Textbox(
                label="Sandbox URL",
                value='https://www.gradio.app/',
                placeholder="Enter sandbox URL",
                lines=1,
                show_label=True,
                elem_id=None,
                elem_classes=None,
                key=None,
            )
            sandboxInteractions = gr.Textbox(
                label="Sandbox Interactions",
                value='[]',
                placeholder="Enter sandbox interactions",
                lines=1,
                show_label=True,
                elem_id=None,
                elem_classes=None,
                key=None,
            )
        with gr.Row():
            sandbox = SandboxComponent(
                label="Sandbox Example",
                value=("https://www.gradio.app/", True, []),
                show_label=True)

        def update_outputs(sandboxData: tuple[str, list[Any]]):
            sandboxUrl, _, sandboxInteractions = sandboxData
            print(
                "UPDATING",
                sandboxData
            )
            return sandboxUrl, str(sandboxInteractions)

        sandbox.change(
            update_outputs,
            inputs=[sandbox],
            outputs=[sandboxUrl, sandboxInteractions]
        )

if __name__ == "__main__":
    demo.launch()

```

## `SandboxComponent`

### 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
tuple[str, bool, list[Any]] | Callable | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">url string and interactions.</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, displayed above the component if `show_label` is `True` 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 corresponds to.</td>
</tr>

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

```python
Timer | float | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.</td>
</tr>

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

```python
Component | Sequence[Component] | set[Component] | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.</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">if True, will display label.</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">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>
</tr>

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

```python
int
```

</td>
<td align="left"><code>160</code></td>
<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>
</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">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</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>

<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">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>
</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">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>
</tr>

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

```python
int | str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.</td>
</tr>
</tbody></table>


### Events

| name | description |
|:-----|:------------|
| `change` | Triggered when the value of the SandboxComponent 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. |
| `input` | This listener is triggered when the user changes the value of the SandboxComponent. |
| `submit` | This listener is triggered when the user presses the Enter key while the SandboxComponent is focused. |



### 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: tuple[str, bool, list[typing.Any]] | None
 ) -> tuple[str, bool, list[typing.Any]] | dict | None:
     return value
 ```
 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gradio-sandboxcomponent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "gradio-custom-component, gradio-template-SimpleTextbox",
    "author": null,
    "author_email": "YOUR NAME <YOUREMAIL@domain.com>",
    "download_url": "https://files.pythonhosted.org/packages/ab/ec/40c2edf4273169c0f918f3f24ae695b5e38e627a981af08acc66542922c7/gradio_sandboxcomponent-0.1.0.tar.gz",
    "platform": null,
    "description": "\n# `gradio_sandboxcomponent`\n<a href=\"https://pypi.org/project/gradio_sandboxcomponent/\" target=\"_blank\"><img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/gradio_sandboxcomponent\"></a>  \n\nGradio library for easily interacting with remote sandbox.\n\n## Installation\n\n```bash\npip install gradio_sandboxcomponent\n```\n\n## Usage\n\n```python\n\nfrom typing import Any\nimport gradio as gr\nfrom gradio_sandboxcomponent import SandboxComponent\n\nexample = SandboxComponent().example_value()\n\n\nwith gr.Blocks() as demo:\n    with gr.Tab(\"Sandbox Demo\"):\n        with gr.Row():\n            gr.Markdown(\"## Sandbox\")\n        with gr.Row():\n            sandboxUrl = gr.Textbox(\n                label=\"Sandbox URL\",\n                value='https://www.gradio.app/',\n                placeholder=\"Enter sandbox URL\",\n                lines=1,\n                show_label=True,\n                elem_id=None,\n                elem_classes=None,\n                key=None,\n            )\n            sandboxInteractions = gr.Textbox(\n                label=\"Sandbox Interactions\",\n                value='[]',\n                placeholder=\"Enter sandbox interactions\",\n                lines=1,\n                show_label=True,\n                elem_id=None,\n                elem_classes=None,\n                key=None,\n            )\n        with gr.Row():\n            sandbox = SandboxComponent(\n                label=\"Sandbox Example\",\n                value=(\"https://www.gradio.app/\", True, []),\n                show_label=True)\n\n        def update_outputs(sandboxData: tuple[str, list[Any]]):\n            sandboxUrl, _, sandboxInteractions = sandboxData\n            print(\n                \"UPDATING\",\n                sandboxData\n            )\n            return sandboxUrl, str(sandboxInteractions)\n\n        sandbox.change(\n            update_outputs,\n            inputs=[sandbox],\n            outputs=[sandboxUrl, sandboxInteractions]\n        )\n\nif __name__ == \"__main__\":\n    demo.launch()\n\n```\n\n## `SandboxComponent`\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\ntuple[str, bool, list[Any]] | Callable | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">url string and interactions.</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\">the label for this component, displayed above the component if `show_label` is `True` 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 corresponds to.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>every</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nTimer | float | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>inputs</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nComponent | Sequence[Component] | set[Component] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.</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\">if True, will display label.</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\">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>\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\n```\n\n</td>\n<td align=\"left\"><code>160</code></td>\n<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>\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\">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</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\">If False, component will be hidden.</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\">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>\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\">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>\n</tr>\n\n<tr>\n<td align=\"left\"><code>key</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.</td>\n</tr>\n</tbody></table>\n\n\n### Events\n\n| name | description |\n|:-----|:------------|\n| `change` | Triggered when the value of the SandboxComponent 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. |\n| `input` | This listener is triggered when the user changes the value of the SandboxComponent. |\n| `submit` | This listener is triggered when the user presses the Enter key while the SandboxComponent is focused. |\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: tuple[str, bool, list[typing.Any]] | None\n ) -> tuple[str, bool, list[typing.Any]] | dict | None:\n     return value\n ```\n \n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Gradio library for easily interacting with remote sandbox.",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [
        "gradio-custom-component",
        " gradio-template-simpletextbox"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2214d03374d1d2bf50861442f752c2173cb1f657161b567a80118af8464ba44a",
                "md5": "96c6983105792a4be66852c238562b2d",
                "sha256": "74072cf6c4e496708687c29206f2a226477ea6b17f4dff03971d707ffe3d7489"
            },
            "downloads": -1,
            "filename": "gradio_sandboxcomponent-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "96c6983105792a4be66852c238562b2d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 1154269,
            "upload_time": "2025-01-14T13:03:33",
            "upload_time_iso_8601": "2025-01-14T13:03:33.125381Z",
            "url": "https://files.pythonhosted.org/packages/22/14/d03374d1d2bf50861442f752c2173cb1f657161b567a80118af8464ba44a/gradio_sandboxcomponent-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "abec40c2edf4273169c0f918f3f24ae695b5e38e627a981af08acc66542922c7",
                "md5": "d0720e45bf371b11e277e78d916fe68a",
                "sha256": "872cca2a7ed06d46a78d4494d60eabbc2b377fbd82bd9e0136df97302dabd57b"
            },
            "downloads": -1,
            "filename": "gradio_sandboxcomponent-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d0720e45bf371b11e277e78d916fe68a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 1193945,
            "upload_time": "2025-01-14T13:03:36",
            "upload_time_iso_8601": "2025-01-14T13:03:36.532368Z",
            "url": "https://files.pythonhosted.org/packages/ab/ec/40c2edf4273169c0f918f3f24ae695b5e38e627a981af08acc66542922c7/gradio_sandboxcomponent-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-14 13:03:36",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gradio-sandboxcomponent"
}
        
Elapsed time: 0.37613s