sonobit commited on
Commit
c50ded2
·
1 Parent(s): 59235d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
2
  import random as rd
3
 
4
  rand = rd.randint(0,9)
5
- #ch = []
6
 
7
  def guess(num):
8
  num = int(num)
@@ -12,14 +11,17 @@ def guess(num):
12
  r = 'ลองกดใหม่นะ'
13
  return r
14
 
 
 
 
15
  with gr.Blocks() as myApp:
16
  with gr.Row():
17
  with gr.Column(scale=1):
18
  inp = gr.Radio(choices=list(range(10)),label='เลือก 1 หมายเลข')
19
- #ch.append(str(i))
20
  with gr.Column(scale=1):
21
  out = gr.Textbox(label='ผลลัพธ์')
22
 
23
  inp.change(guess,inp,out)
24
-
25
  myApp.launch()
 
2
  import random as rd
3
 
4
  rand = rd.randint(0,9)
 
5
 
6
  def guess(num):
7
  num = int(num)
 
11
  r = 'ลองกดใหม่นะ'
12
  return r
13
 
14
+ def answer():
15
+ return str(rand)
16
+
17
  with gr.Blocks() as myApp:
18
  with gr.Row():
19
  with gr.Column(scale=1):
20
  inp = gr.Radio(choices=list(range(10)),label='เลือก 1 หมายเลข')
21
+ btn = gr.Button(value="เฉลย")
22
  with gr.Column(scale=1):
23
  out = gr.Textbox(label='ผลลัพธ์')
24
 
25
  inp.change(guess,inp,out)
26
+ btn.click(fn=answer,outputs=out)
27
  myApp.launch()