GUI / app.py
unim4er's picture
Update app.py
c933b28
raw
history blame contribute delete
738 Bytes
import gradio as gr
import random as rd
rand = rd.randint(0,9)
def guess(num):
num = int(num)
if num == rend:
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,inp,out)
btn.click(fn=answer,outputs=out)
myApp.launch()