| import gradio as gr | |
| demo = gr.Blocks() | |
| def dummy(tb, sl): | |
| tbo = tb + " " + " "+ str(sl) | |
| num = sl | |
| print(tb + " " + " "+ str(sl)) | |
| cb = ['usa', 'japan', ] | |
| if sl > 50: | |
| raise gr.Error("This is not allowed!!!!!!!") | |
| return tbo, num, cb | |
| with demo: | |
| tb = gr.Textbox() | |
| sl = gr.Slider(minimum=1, maximum=100, step=5, info="hhe hhah kki ko") | |
| b1 = gr.Button('button') | |
| tbo = gr.Textbox() | |
| num = gr.Number() | |
| cb = gr.CheckboxGroup(label = "countries", choices= ["india", "usa", "japan"], value="usa") | |
| b1.click(dummy, [tb, sl], [tbo, num, cb] ) | |
| examples = gr.Examples([["dd", 1], ["ggg", 4], ["kjkjk", 6]], | |
| [tb, sl], | |
| [tbo, num, cb], | |
| dummy, cache_examples=True) | |
| demo.launch() | |