File size: 522 Bytes
57a9f28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# 定義抽籤選項
choices = ["大吉", "中吉", "小吉", "吉", "凶"]

# 抽籤函數
def draw_lot():
    return random.choice(choices)

# 建立 Gradio 介面
with gr.Blocks() as demo:
    gr.Markdown("### 抽籤系統")
    result = gr.Textbox(label="抽籤結果", interactive=False)
    button = gr.Button("抽籤")
    
    # 點擊按鈕後,呼叫 draw_lot 函數更新結果
    button.click(fn=draw_lot, inputs=[], outputs=[result])

# 啟動 Gradio 介面
demo.launch()