rjiang12 commited on
Commit
0ae8261
·
1 Parent(s): bfa5203

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -8,7 +8,10 @@ def func(percent, numBlocks):
8
  numEmpty = numBlocks - numFilled
9
  print(f"numEmpty: {numEmpty}")
10
  HTMLstr = filledSquares * numFilled + emptySquares * numEmpty
11
- return HTMLstr
 
 
 
12
 
13
 
14
  css_adds = ".tooltiptext {visibility: hidden;width:50ch;margin-left:-25ch;top: 100%;left: 50%;background-color: #222;text-align: center;border-radius: 6px;padding: 5px 0;position: absolute;z-index: 1;} \
@@ -19,6 +22,8 @@ with gr.Blocks(css=css_adds) as demo:
19
  percent = gr.Slider(1, 100, value=50, step=1, label="percentage")
20
  numBlocks = gr.Slider(3, 20, value=4, step=1, label="number of blocks")
21
  button = gr.Button("button")
22
- button.click(func, inputs=[percent, numBlocks], outputs=gr.HTML())
 
 
23
  # hi
24
  demo.launch()
 
8
  numEmpty = numBlocks - numFilled
9
  print(f"numEmpty: {numEmpty}")
10
  HTMLstr = filledSquares * numFilled + emptySquares * numEmpty
11
+ return (
12
+ gr.update(value=HTMLstr),
13
+ gr.update(value=HTMLstr)
14
+ )
15
 
16
 
17
  css_adds = ".tooltiptext {visibility: hidden;width:50ch;margin-left:-25ch;top: 100%;left: 50%;background-color: #222;text-align: center;border-radius: 6px;padding: 5px 0;position: absolute;z-index: 1;} \
 
22
  percent = gr.Slider(1, 100, value=50, step=1, label="percentage")
23
  numBlocks = gr.Slider(3, 20, value=4, step=1, label="number of blocks")
24
  button = gr.Button("button")
25
+ html1 = gr.HTML()
26
+ html2 = gr.HTML()
27
+ button.click(func, inputs=[percent, numBlocks], outputs=[html1, html2])
28
  # hi
29
  demo.launch()