Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -1,10 +1,19 @@
1
  import gradio as gr
2
  import random as rd
3
-
 
 
 
 
 
 
 
4
  with gr.Blocks() as myApp:
5
  with gr.Row():
6
  with gr.Column(scale=1):
7
  inp = gr.Radio(choices=list(range(10)),lable='เลือก 1 หมายเลข')
8
  with gr.Column(scale=1):
9
  out = gr.Textbox(lable='ผลลัพธ์')
 
 
10
  myApp.launch()
 
1
  import gradio as gr
2
  import random as rd
3
+ rand = rd.randint(9,0)
4
+ def guess(num):
5
+ num = int(num)
6
+ if num == rand:
7
+ r = 'ทายถูกแล้วนะ'
8
+ else:
9
+ r = 'ลองกดใหม่นะ'
10
+ return r
11
  with gr.Blocks() as myApp:
12
  with gr.Row():
13
  with gr.Column(scale=1):
14
  inp = gr.Radio(choices=list(range(10)),lable='เลือก 1 หมายเลข')
15
  with gr.Column(scale=1):
16
  out = gr.Textbox(lable='ผลลัพธ์')
17
+ inp.change(guess,inp,out)
18
+ btn.click(fn=answer,outputs=out)
19
  myApp.launch()