Gradio: How to "Clear" everything w/ Blocks?
How can we clear everything on the page, the way the simple interface’s Clear button does it?I tried adding a button and cycling through all elements and callingx.clear()on each one, but it either has no effect or I get errors.  I’ve looked all over the docs but can only find an example of clearing a single Chatbot interface.  I’ve got multiple audio inputs and text inputs, and such. With the simple interface the Clear button automatically worked.  So… how do we implement that?Thanks.
2023-05-01T14:23:09Z
Hi@drscotthawley!ReturningNonefrom an event as the value for a component has the same effect as theClearbutton.
2023-05-01T16:24:22Z
@freddyaboultonThanks for your reply.Ok, I just now triedclear_btn.click(lambda: None)but it had no effect: none of my elements (e.g. Audio inputs) cleared when i pressed the button.  Could you please be more specific?  ThanksHere’s more of my code right now:inputs = [audio1, textprompt1, audio2, textprompt2, interp_slider, batch_slider,
                        cfg_slider, crossfade_secs, init_audio, init_str_slider]
        outputs = [output_audio, embed_plot]
        wrapper = partial(process_audio, device, verbose=verbose) 

        submit_btn.click(fn=wrapper, inputs=inputs, outputs=outputs)
        clear_btn.click(lambda: None )
2023-05-01T16:35:24Z
Can try viaoutputs=outputsin theclickmethod?
2023-05-01T16:44:42Z
@freddyaboultonSure. I had tried that earlier;clear_btn.click(lambda: None, outputs=outputs )…but was and am still getting the error:An event handler didn't receive enough output values (needed: 2, received: 1). Wanted outputs: [audio, plot] Received outputs: [None]Oh, perhpas I need to dolambda: [None]*2? …that hadn’t occurred to me.
2023-05-01T16:46:55Z
Ok that works!… but when I try it on my Slider items, rather than being restored to their default values, they all get moved all the way to the left.  Is there a way to have them reset to the default (“value”) i specified when I setup the Sliders?
2023-05-01T16:53:09Z
Yep - needs to be None for each component!Yes, if you store the default variable inSLIDER_DEFAULT, return that instead of None. So if it’s the second element ofoutputs, do something likeclear_btn.click(lambda: [None, 5], outputs=[Audio, Slider])
2023-05-01T16:56:11Z
Thank you!  All done!