How to close Gradio GUI in jupyter after button click?
Hey everyone. I’m using a jupyter lab notebook and I’d like it if after getting the inputs from the user (me), the gradio app would close the server port and even better, disappear.So for example, a user would write in jupyter:start_process()and a gui would appear right below the cell with some sliders or whatever, asking for the user input. Then the user would click the “submit” button, and the user interface would disappear, the server port would close, and the real process would begin, with some parameters set by the aforementioned sliders.I’ve tried something like this:with gr.Blocks() as demo:
    def process_and_close(*args):
        demo.clear()
        demo.close()
        # do stuff with args

    a = gr.Slider(label="Variable a")
    btn = gr.Button("Submit")
    btn.click(fn=process_and_close, inputs=a, outputs=None)

demo.launch()but it just stops working, it doesn’t disappear. I think it might close the server, but the gui stays there.
2022-09-14T22:48:16Z
You could hide the visibility of the Blocks. For example, wrap all of the components in agr.Column()and then update the visibility of the column to False.Here’s a working example:import gradio as gr

with gr.Blocks() as demo:
    col = gr.Column()
    with col:
        box = gr.Textbox(value="hi")
        btn = gr.Button()
    
    btn.click(lambda :gr.update(visible=False), None, col)
demo.launch()