songs1 commited on
Commit
42cd864
·
1 Parent(s): 1dbb331

enable tab selectors + case download

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -544,22 +544,22 @@ with gr.Blocks(css_paths="style.css") as demo:
544
 
545
  with gr.Row():
546
  # Tab selectors
547
- tab_buttons = dict()
548
  with gr.Column(scale=1, min_width=250):
549
  for tab_name in TAB_NAMES:
550
  tab_button = gr.Button(
551
  value=tab_name,
552
  variant="primary" if tab_name == TAB_NAMES[0] else "secondary",
553
  )
554
- tab_buttons[tab_name] = tab_button
555
 
556
  # Filter cards
557
- tab_containers = dict()
558
- filter_cards = dict()
559
  for tab in CONFIG["tabs"]:
560
  visible = tab["name"] == TAB_NAMES[0] # default first card
561
  with gr.Column(scale=4, visible=visible) as tab_container:
562
- tab_containers[tab["name"]] = tab_container
563
  with gr.Row(elem_classes=["card-group"]):
564
  for card in tab["cards"]:
565
  if isinstance(card["values"], list):
@@ -595,24 +595,24 @@ with gr.Blocks(css_paths="style.css") as demo:
595
  elem_classes=["filter-card", "filter-range"],
596
  )
597
 
598
- filter_cards[card["name"]] = filter_card
599
 
600
  # Assign tab buttons to toggle visibility
601
- # for tab_button, name in zip(tab_buttons, TAB_NAMES):
602
- # tab_button.click(
603
- # fn=set_active_tab,
604
- # inputs=gr.State(name),
605
- # outputs=tab_containers + tab_buttons,
606
- # api_name=False,
607
- # )
608
 
609
  # Enable case download
610
- # case_download.click(
611
- # fn=None, # apparently this isn't the same as not specifying it
612
- # js=DOWNLOAD_CASES_JS,
613
- # inputs=json_output,
614
- # api_name=False,
615
- # )
616
 
617
  # Load initial counts on startup
618
  # demo.load(
 
544
 
545
  with gr.Row():
546
  # Tab selectors
547
+ tab_buttons = []
548
  with gr.Column(scale=1, min_width=250):
549
  for tab_name in TAB_NAMES:
550
  tab_button = gr.Button(
551
  value=tab_name,
552
  variant="primary" if tab_name == TAB_NAMES[0] else "secondary",
553
  )
554
+ tab_buttons.append(tab_button)
555
 
556
  # Filter cards
557
+ tab_containers = []
558
+ filter_cards = []
559
  for tab in CONFIG["tabs"]:
560
  visible = tab["name"] == TAB_NAMES[0] # default first card
561
  with gr.Column(scale=4, visible=visible) as tab_container:
562
+ tab_containers.append(tab_container)
563
  with gr.Row(elem_classes=["card-group"]):
564
  for card in tab["cards"]:
565
  if isinstance(card["values"], list):
 
595
  elem_classes=["filter-card", "filter-range"],
596
  )
597
 
598
+ filter_cards.append(filter_card)
599
 
600
  # Assign tab buttons to toggle visibility
601
+ for tab_button, name in zip(tab_buttons, TAB_NAMES):
602
+ tab_button.click(
603
+ fn=set_active_tab,
604
+ inputs=gr.State(name),
605
+ outputs=tab_containers + tab_buttons,
606
+ api_name=False,
607
+ )
608
 
609
  # Enable case download
610
+ case_download.click(
611
+ fn=None, # apparently this isn't the same as not specifying it
612
+ js=DOWNLOAD_CASES_JS,
613
+ inputs=json_output,
614
+ api_name=False,
615
+ )
616
 
617
  # Load initial counts on startup
618
  # demo.load(