broadfield commited on
Commit
b3b21d5
·
verified ·
1 Parent(s): 550e4b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -62,8 +62,7 @@ def search(q,rn,st):
62
  return(json.dumps(cont,indent=4)),html
63
  def next_show(cur):
64
  new=int(cur)+10
65
- html_out=f"<div>Showing {cur} through {new}</div>"
66
- return gr.update(visible=True),html_out,new
67
 
68
  def prev_show(cur):
69
  if int(cur)-10 <=0:
@@ -72,8 +71,11 @@ def prev_show(cur):
72
  else:
73
  new=int(cur)-10
74
  out_gr=gr.update(visible=True)
75
- html_out=f"<div>Showing {new} through {cur}</div>"
76
- return out_gr,html_out,new
 
 
 
77
 
78
  with gr.Blocks(css=style,head=head) as b:
79
  with gr.Group():
@@ -90,8 +92,8 @@ with gr.Blocks(css=style,head=head) as b:
90
 
91
  hid_start=gr.Number(step=1,value=0,visible=True)
92
 
93
- next_btn.click(next_show,[hid_start],[prev_btn,show_html,hid_start]).then(search,[query,num,hid_start],[json_out,html_out])
94
- prev_btn.click(next_show,[hid_start],[prev_btn,show_html,hid_start]).then(search,[query,num,hid_start],[json_out,html_out])
95
 
96
- sub.click(search,[query,num,hid_start],[json_out,html_out])
97
  b.launch()
 
62
  return(json.dumps(cont,indent=4)),html
63
  def next_show(cur):
64
  new=int(cur)+10
65
+ return gr.update(visible=True),new
 
66
 
67
  def prev_show(cur):
68
  if int(cur)-10 <=0:
 
71
  else:
72
  new=int(cur)-10
73
  out_gr=gr.update(visible=True)
74
+ return out_gr,new
75
+ def show_num(cur):
76
+ new=int(cur)+10
77
+ html_out=f"<div>Showing {cur} through {new}</div>"
78
+ return html_out
79
 
80
  with gr.Blocks(css=style,head=head) as b:
81
  with gr.Group():
 
92
 
93
  hid_start=gr.Number(step=1,value=0,visible=True)
94
 
95
+ next_btn.click(next_show,[hid_start],[prev_btn,hid_start]).then(show_num,hid_start,show_html).then(search,[query,num,hid_start],[json_out,html_out])
96
+ prev_btn.click(next_show,[hid_start],[prev_btn,hid_start]).then(show_num,hid_start,show_html).then(search,[query,num,hid_start],[json_out,html_out])
97
 
98
+ sub.click(search,[query,num,hid_start],[json_out,html_out]).then(show_num,hid_start,show_html)
99
  b.launch()