unim4er commited on
Commit
cdd3b33
1 Parent(s): f57bd5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -1,10 +1,20 @@
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)),label='เลือก1หมายเลข')
 
8
  with gr.Column(scale=1):
9
  out = gr.Textbox(label='ผลลัพธ์')
 
 
10
  myApp.launch()
 
1
  import gradio as gr
2
  import random as rd
3
+ rand = rd.randint(0,9)
4
+ def guess(num):
5
+ reture 'เลขที่สุ่มได้ คือ'+str(rand)
6
+ num = int(num)
7
+ if num == rand:
8
+ r = 'ทายถูกแล้ว'
9
+ else:
10
+ 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)),label='เลือก1หมายเลข')
15
+ btn = br.Buttun(value="เฉลย")
16
  with gr.Column(scale=1):
17
  out = gr.Textbox(label='ผลลัพธ์')
18
+ inp.change(guess,inp,out)
19
+ btn.click(fn=answer,outputs=out)
20
  myApp.launch()