Spaces:
Sleeping
Sleeping
File size: 604 Bytes
955f4ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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()
|