gradio/demo/gallery_component_events/run.py
Freddy Boulton 92278729ee
Gallery preview fix and optionally skip download of urls in postprcess (#6288)
* Add code

* add changeset

* Use urls from our s3 bucket

* Add notebook code

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2023-11-03 18:39:25 -04:00

25 lines
749 B
Python

import gradio as gr
with gr.Blocks() as demo:
cheetahs = [
"https://gradio-builds.s3.amazonaws.com/assets/cheetah-003.jpg",
"https://gradio-builds.s3.amazonaws.com/assets/lite-logo.png",
"https://gradio-builds.s3.amazonaws.com/assets/TheCheethcat.jpg",
]
with gr.Row():
with gr.Column():
btn = gr.Button()
with gr.Column():
gallery = gr.Gallery()
with gr.Column():
select_output = gr.Textbox(label="Select Data")
btn.click(lambda: cheetahs, None, [gallery])
def select(select_data: gr.SelectData):
return select_data.value['image']['url']
gallery.select(select, None, select_output)
if __name__ == "__main__":
demo.launch()