Hi, everyone.
Iβm new in gradio and would like to know if someone can help me.
I want to add a hidden figure component in my app, and when the button is click, I want to update the figure component and make it visible, and then show my output in the figure component.
I have seen some examples, however, some of them do the execution and then the figure component is updated.
I want to start the execution, make visible the component, wait for the results and then show it in the visible component.
Is that possible?
Thanks for the help
Hi, everyone.
I could solve it using the then method.
I left a similar example in case someone need it.
import gradio as gr
import time
counter = 1
def visible_component(input_text):
return gr.update(visible=True)
def generate_output(input_text):
#gr.update(output_text,visible=True)
global counter
time.sleep(2)
output_text = "Hello, " + input_text + "!"
counter += 1
return output_text
with gr.Blocks() as demo:
with gr.Row():
# column for inputs
with gr.Column():
input_text = gr.Textbox(label="Input Text")
submit_button = gr.Button("Submit")
# column for outputs
with gr.Column():
output_text = gr.Textbox(visible=False)
submit_button.click(
fn=visible_component,
inputs=input_text,
outputs=output_text
).then(
#time.sleep(2),
fn=generate_output,
inputs=input_text,
outputs=output_text
)
demo.launch()
1 Like
Facing this Gradio API call error:
File β/home/user/.local/lib/python3.10/site-packages/gradio_client/client.pyβ, line 824, in _predict
raise ValueError(result[βerrorβ])
ValueError: None
Is there a kind of full guide regarding using Gradio api including named APIs and unnamed fn_index APIs?
Thanks and expecting an answer.