CoolFace
Apppublic

Gitf/GUI

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
app.py22 linesDownload Raw Back to root
1import gradio as gr2import random as rd3rand = rd.randint(0,9)4def guess(num):5    num = int(num)6    if num == rand:7        r = 'ทายถูกแล้ว'8    else:9        r = 'ลองกดใหม่นะ'10    return r11def answer():12    return 'เลขที่สุ่มได้ คือ '+str(rand)13with gr.Blocks() as myApp:14    with gr.Row():15        with gr.Column(scale=1):16            inp = gr.Radio(choices=list(range(10)),label='เลือก 1 หมายเลข')17            btn = gr.Button(value="เฉลย")18        with gr.Column(scale=1):19            out = gr.Textbox(label='ผลลัพธ์')20        inp.change(guess,inp,out)21        btn.click(fn=answer,outputs=out)22myApp.launch()