xp3857 commited on
Commit
0ec4659
1 Parent(s): db124c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -67,8 +67,11 @@ def ac():
67
  with gr.Blocks(css=css) as b:
68
 
69
  with gr.Row():
70
- put = gr.Textbox()
71
- btn1 = gr.Button()
 
 
 
72
  message=gr.HTML("", visible=False)
73
  with gr.Row():
74
  out1 = gr.Image()
@@ -81,19 +84,17 @@ def ac():
81
  h=gr.Textbox(value="V")
82
  t_state=gr.Number()
83
  t_switch=gr.Textbox(value=0)
84
-
 
85
  fac_b = gr.Textbox(value="",visible=False)
86
  btn1.click(cl_fac,None,[fac_b,message])
87
-
88
  b1=btn1.click(start,None,[t_state,t_switch])
89
  sta = t_state.change(end,t_state,[t_switch,message],every=1,show_progress=False)
90
-
91
  b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
92
  b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b])
93
  b4=out2.change(im_fn,[put,fac_b,h],[out3,fac_b])
94
  b5=out3.change(im_fn,[put,fac_b,h],[out4,fac_b])
95
-
96
- t_switch.change(clear,None,[t_switch,fac_b], cancels=[sta,b2,b3,b4,b5])
97
-
98
  b.queue(concurrency_count=100).launch(show_api=False)
99
  ac()
 
67
  with gr.Blocks(css=css) as b:
68
 
69
  with gr.Row():
70
+ put = gr.Textbox()
71
+ with gr.Column():
72
+ with gr.Row():
73
+ btn1 = gr.Button("Run")
74
+ btn2 = gr.Button("Clear")
75
  message=gr.HTML("", visible=False)
76
  with gr.Row():
77
  out1 = gr.Image()
 
84
  h=gr.Textbox(value="V")
85
  t_state=gr.Number()
86
  t_switch=gr.Textbox(value=0)
87
+ def clear_all():
88
+ return "",None,None,None,None,None,None,None
89
  fac_b = gr.Textbox(value="",visible=False)
90
  btn1.click(cl_fac,None,[fac_b,message])
 
91
  b1=btn1.click(start,None,[t_state,t_switch])
92
  sta = t_state.change(end,t_state,[t_switch,message],every=1,show_progress=False)
 
93
  b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
94
  b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b])
95
  b4=out2.change(im_fn,[put,fac_b,h],[out3,fac_b])
96
  b5=out3.change(im_fn,[put,fac_b,h],[out4,fac_b])
97
+ swi=t_switch.change(clear,None,[t_switch,fac_b], cancels=[sta,b2,b3,b4,b5])
98
+ btn2.click(clear_all, None,[fac_b,put,out1,out2,out3,out4,t_state,t_switch],cancels=[b1,sta,b2,b3,b4,b5,swi])
 
99
  b.queue(concurrency_count=100).launch(show_api=False)
100
  ac()