Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def func(percent, numBlocks):
|
4 |
+
filledSquares = "<div style='height:50px;width:50px;background-color:#555;display:inline-block'></div> "
|
5 |
+
emptySquares = "<div style='height:50px;width:50px;background-color:#999;display:inline-block'></div> "
|
6 |
+
numFilled = round(round(percent/100) * numBlocks)
|
7 |
+
numEmpty = numBlocks - numFilled
|
8 |
+
HTMLstr = filledSquares * numFilled + emptySquares * numEmpty
|
9 |
+
return HTMLstr
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
percent = gr.Slider(1, 100, value=50)
|
15 |
+
numBlocks = gr.Slider(3, 20, value=4)
|
16 |
+
button = gr.Button("button")
|
17 |
+
button.click(func, inputs=[percent, numBlocks], outputs=gr.HTML())
|
18 |
+
|
19 |
+
demo.launch()
|