Spaces:
Sleeping
Sleeping
File size: 809 Bytes
70455bb f1e0876 4349de9 6dd7921 70455bb 6dd7921 70455bb 12bc024 70455bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
def func(percent, numBlocks):
filledSquares = "<div style='height:5px;width:5px;background-color:#555;display:inline-block'></div> "
emptySquares = "<div style='height:5px;width:5px;background-color:#999;display:inline-block'></div> "
numFilled = round((percent/100) * numBlocks)
print(f"numFilled: {numFilled}")
numEmpty = numBlocks - numFilled
print(f"numEmpty: {numEmpty}")
HTMLstr = filledSquares * numFilled + emptySquares * numEmpty
return HTMLstr
with gr.Blocks() as demo:
percent = gr.Slider(1, 100, value=50, step=1, label="percentage")
numBlocks = gr.Slider(3, 20, value=4, step=1, label="number of blocks")
button = gr.Button("button")
button.click(func, inputs=[percent, numBlocks], outputs=gr.HTML())
demo.launch() |