Passing an additional argument to a function
HiCan I pass an additional argument that is not an input in a Button.click?something like:gr.clickbtn.click(fn=myfunction(aditional_argument)Thank you for your great support and for the developers for making Gradio!
2022-10-28T14:46:34Z
Hi@LittleWing! Unfortunately,clickdoes not support arbitrary **kwargs. What are you trying to accomplish? There might be another way!
2022-10-28T19:37:02Z
Hi@freddyaboultonThanks for the quick reply!I’ll try to explain,I’m trying to write a code that connects to various switches (Networking) in my organizationI’m sending an api requests via therequestslibrary.I have 2 buttons:‘show selected switches version’upgrade selected switcheslets say a user pressed button number 1 for switch x, the code will send a login api request which grabs the cookie for switch xif he will then press button number 2 to upgrade switch x the code will send another login api requestresulting with a new cookie, which I don’t wantBecause theButton.clickbinds one function per button I couldn’t find a way to bypass that there wont be a new request for every button.Thanks
2022-11-03T14:34:22Z
Hi@LittleWing! Sorry it took me a while to get back to you.Can you use a gr.Variable/gr.State (State In Blocks) to keep track of whether the first button is clicked before the second one?
2022-11-05T16:03:21Z
Hi,Thank you for the reply and support!Its certainly a valid option to try!- I’ll give it a shot! , I will update if new issues ariseThank you so much@freddyaboulton