Spaces:
Sleeping
Sleeping
import gradio as gr | |
import random | |
def draw_lottery(max_number): | |
return random.randint(1, max_number) | |
with gr.Blocks() as demo: | |
# 班級座號最大值輸入框 | |
max_number_input = gr.Number(label="班級座號最大值", value=50) | |
# 抽籤按鈕與結果顯示 | |
draw_button = gr.Button("抽籤") | |
result_output = gr.Textbox(label="抽中的號碼", interactive=False) | |
# 點擊按鈕時執行抽籤函數 | |
draw_button.click(fn=draw_lottery, | |
inputs=max_number_input, | |
outputs=result_output) | |
# 啟動介面 | |
demo.launch() | |