File size: 742 Bytes
a63d216 616a09b 3a502c7 616a09b 0a240cb d58418f 616a09b d58418f 0a240cb 07fe9d0 616a09b 0a240cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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(scale=1):
out = gr.Textbox(label='ผลลัพธ์')
inp.change(guess,ino,out)
btn.clink(fn=answer,output=out)
myApp.launch()
|