File size: 896 Bytes
1c9929f
 
 
33857c6
d3f56d0
5036ffb
8d6b0d8
1c9929f
33857c6
1c9929f
 
 
3a61ef8
5ac28e2
c50ded2
 
3a61ef8
515ad80
 
 
 
d1782d3
1c9929f
 
972d3ab
c50ded2
b1741c2
1c9929f
 
 
e63b587
c50ded2
bd92e86
1c9929f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import random as rd

rand = []
rand.append(rd.randint(0,9))

def guess(num):
    num = int(num)
    if num == rand[0]:
        r = 'ทายถูกแล้ว'
    else:
        r = 'ลองกดใหม่นะ'
    return r  
    
def answer():
    return str(rand)

def newRand():
    rand[0]= rd.randint(0,9)
    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="เฉลย")
                btn2 = gr.Button(value="สุ่มใหม่")
        with gr.Column(scale=1):
            out = gr.Textbox(label='ผลลัพธ์')
            
    inp.change(guess,inp,out)  
    btn.click(fn=answer,outputs=out)
    btn2.click(fn=newRand,outputs=out)
myApp.launch()