File size: 659 Bytes
fafd17b
 
 
 
 
 
ab50d62
fafd17b
ab50d62
fafd17b
 
ab50d62
 
 
 
 
 
 
 
 
 
 
7f47705
ab50d62
 
 
 
fafd17b
ab50d62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
import os
import sys
import json 
import requests

import gradio as gr

js = "(x) => confirm('Are you sure?')"



with gr.Blocks() as demo:
    btn = gr.Button()
    hidden_checkbox = gr.Checkbox(visible=False)
    textbox = gr.Textbox()
    num = gr.Number()
    
    def hidden_checkbox_fn(checkbox_state, number):
        if checkbox_state:
            number += 1
        display = f'confirmed {number} times'
        return False, display, number
        
    
    btn.click(None, None, hidden_checkbox, _js=js)
    hidden_checkbox.change(hidden_checkbox_fn, [hidden_checkbox, num], [hidden_checkbox, textbox, num])
    
demo.launch()