Spaces:
Runtime error
Runtime error
| tags: [gradio-custom-component, SimpleTextbox] | |
| title: gradio_iframecomponent | |
| short_description: iframe | |
| colorFrom: blue | |
| colorTo: yellow | |
| sdk: gradio | |
| pinned: false | |
| app_file: space.py | |
| # `gradio_iframecomponent` | |
| <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange"> | |
| iframe | |
| ## Installation | |
| ```bash | |
| pip install gradio_iframecomponent | |
| ``` | |
| ## Usage | |
| ```python | |
| import gradio as gr | |
| from gradio_iframecomponent import IFrame | |
| def create_demo(): | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# IFrame Component Demo") | |
| iframe = IFrame( | |
| label="Web Page Viewer", | |
| value="https://www.gradio.app", | |
| interactive=True, | |
| height=500 | |
| ) | |
| url_input = gr.Textbox( | |
| label="Enter URL", | |
| placeholder="https://example.com" | |
| ) | |
| load_btn = gr.Button("Load URL") | |
| load_btn.click( | |
| fn=lambda url: url, | |
| inputs=url_input, | |
| outputs=iframe | |
| ) | |
| return demo | |
| if __name__ == "__main__": | |
| demo = create_demo() | |
| demo.launch() | |
| ``` | |
| ## `IFrame` | |
| ### 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 | |
| ``` | |
| </td> | |
| <td align="left"><code>""</code></td> | |
| <td align="left">None</td> | |
| </tr> | |
| <tr> | |
| <td align="left"><code>src</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>width</code></td> | |
| <td align="left" style="width: 25%;"> | |
| ```python | |
| str | int | |
| ``` | |
| </td> | |
| <td align="left"><code>"100%"</code></td> | |
| <td align="left">None</td> | |
| </tr> | |
| <tr> | |
| <td align="left"><code>height</code></td> | |
| <td align="left" style="width: 25%;"> | |
| ```python | |
| str | int | |
| ``` | |
| </td> | |
| <td align="left"><code>400</code></td> | |
| <td align="left">None</td> | |
| </tr> | |
| <tr> | |
| <td align="left"><code>sandbox</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>interactive</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>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>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>show_label</code></td> | |
| <td align="left" style="width: 25%;"> | |
| ```python | |
| bool | |
| ``` | |
| </td> | |
| <td align="left"><code>True</code></td> | |
| <td align="left">None</td> | |
| </tr> | |
| </tbody></table> | |
| ### Events | |
| | name | description | | |
| |:-----|:------------| | |
| | `change` | Triggered when the value of the IFrame 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 IFrame. | | |
| ### 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. | |
| ```python | |
| def predict( | |
| value: str | None | |
| ) -> str | None: | |
| return value | |
| ``` | |