File size: 729 Bytes
70faef9
816e9e6
8b6319c
 
 
 
 
 
 
c27f326
 
 
05c5984
b02ac49
 
4a6839f
8b6319c
b02ac49
05c5984
8b6319c
a0f8858
05c5984
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 as rd
rand = rd.randint(0,9)
def guess(num):
    num = int(num)
    if num == rand:
        r = 'ทายถูกแล้ว'
    else:
        r = 'ลองกดใหม่นะ'
    return r
def answer():
    return 'เลขที่สุ่มได้ คือ '+str(rand)
with gr.Blocks() as myApp:
    with gr.Row():
        with gr.Column(scale=1):
           inp = gr.Radio(choices=list(range(10)),label='เลือก 1 หมายเลข')
           btn = gr.Button(Value="เฉลย")
        with gr.Column(scaie=1):
          out = gr.Textbox(label='ผลลัพธ์')
        inp.change(guess,inp,out)
        btn.click(fn=answer,outputs=out)
myApp.launch()