Spaces:
Runtime error
Runtime error
File size: 741 Bytes
8553f46 2c54e32 220879f a605ba3 2c54e32 8553f46 1688c28 8553f46 1688c28 2c54e32 8553f46 |
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='เลือกตัวเลข')
btn =gr.Button(value='เฉลย')
with gr.Column(scale=1):
out=gr.Textbox(label='ผลลัพธ์')
inp.change(guess,inp,out)
btn.click(fn=answer,outputs=out)
myApp.launch()
|