Spaces:
Runtime error
Runtime error
A newer version of the Gradio SDK is available:
5.34.2
metadata
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
iframe
Installation
pip install gradio_iframecomponent
Usage
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
name | type | default | description |
---|---|---|---|
value |
|
"" |
None |
src |
|
None |
None |
width |
|
"100%" |
None |
height |
|
400 |
None |
sandbox |
|
None |
None |
interactive |
|
True |
None |
visible |
|
True |
None |
elem_id |
|
None |
None |
elem_classes |
|
None |
None |
render |
|
True |
None |
label |
|
None |
None |
show_label |
|
True |
None |
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.
def predict(
value: str | None
) -> str | None:
return value