audrey06100 commited on
Commit
408d434
·
1 Parent(s): efa3bef
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -437,8 +437,8 @@ with gr.Blocks() as demo:
437
  "count" : 1,
438
  "totalNum" : len(stage1_info["missingTemplates"])
439
  }
440
- name = stage1_info["missingTemplates"][0]
441
- label = '{} (1/{})'.format(name, stage1_info["step2"]["totalNum"])
442
 
443
  stage1_info["state"] = "step2-selecting"
444
  # determine which button to display
@@ -567,7 +567,7 @@ with gr.Blocks() as demo:
567
  "totalNum" : len(stage1_info["missingTemplates"])
568
  }
569
  tpl_name = stage1_info["missingTemplates"][0]
570
- chkbox_label = '{} (1/{})'.format(tpl_name, stage1_info["step3"]["totalNum"])
571
 
572
  tpl_idx = channel_info["templateDict"][tpl_name]["index"]
573
  chkbox_value = stage1_info["mappingResults"][0]["newOrder"][tpl_idx]
@@ -581,7 +581,7 @@ with gr.Blocks() as demo:
581
  in_fillmode : gr.Dropdown(visible=False),
582
  fillmode_btn : gr.Button(visible=False),
583
  chkbox_group : gr.CheckboxGroup(choices=channel_info["inputOrder"],
584
- value=chkbox_value, label=chkbox_label, visible=True),
585
  next_btn : gr.Button(visible=True)}
586
  else:
587
  yield {stage1_json : stage1_info,
@@ -589,7 +589,7 @@ with gr.Blocks() as demo:
589
  in_fillmode : gr.Dropdown(visible=False),
590
  fillmode_btn : gr.Button(visible=False),
591
  chkbox_group : gr.CheckboxGroup(choices=channel_info["inputOrder"],
592
- value=chkbox_value, label=chkbox_label, visible=True),
593
  step3_btn : gr.Button(visible=True)}
594
 
595
  # =======================================step3-2========================================
@@ -690,7 +690,7 @@ with gr.Blocks() as demo:
690
  stage1_info["unassignedInputs"] = app_utils.get_unassigned_inputs(channel_info["inputOrder"], channel_info["inputDict"])
691
 
692
  tpl_name = stage1_info["missingTemplates"][step2["count"]-1]
693
- radio_label = '{} ({}/{})'.format(tpl_name, step2["count"], step2["totalNum"])
694
 
695
  stage1_info["step2"] = step2
696
  # determine which button to display
@@ -698,14 +698,14 @@ with gr.Blocks() as demo:
698
  return {stage1_json : stage1_info,
699
  channel_json : channel_info,
700
  radio_group : gr.Radio(choices=stage1_info["unassignedInputs"],
701
- value=[], label=radio_label),
702
  step2_btn : gr.Button(visible=False),
703
  next_btn : gr.Button(visible=True)}
704
  else:
705
  return {stage1_json : stage1_info,
706
  channel_json : channel_info,
707
  radio_group : gr.Radio(choices=stage1_info["unassignedInputs"],
708
- value=[], label=radio_label)}
709
  step2_btn.click(
710
  fn = update_radio,
711
  inputs = [stage1_json, channel_json, radio_group],
@@ -734,7 +734,7 @@ with gr.Blocks() as demo:
734
  step3["count"] += 1
735
 
736
  tpl_name = stage1_info["missingTemplates"][step3["count"]-1]
737
- chkbox_label = '{} ({}/{})'.format(tpl_name, step3["count"], step3["totalNum"])
738
 
739
  tpl_idx = channel_info["templateDict"][tpl_name]["index"]
740
  chkbox_value = stage1_info["mappingResults"][0]["newOrder"][tpl_idx]
@@ -744,12 +744,12 @@ with gr.Blocks() as demo:
744
  # determine which button to display
745
  if step3["count"] == step3["totalNum"]:
746
  return {stage1_json : stage1_info,
747
- chkbox_group : gr.CheckboxGroup(value=chkbox_value, label=chkbox_label),
748
  step3_btn : gr.Button(visible=False),
749
  next_btn : gr.Button(visible=True)}
750
  else:
751
  return {stage1_json : stage1_info,
752
- chkbox_group : gr.CheckboxGroup(value=chkbox_value, label=chkbox_label)}
753
 
754
  fillmode_btn.click(
755
  fn = init_next_step,
 
437
  "count" : 1,
438
  "totalNum" : len(stage1_info["missingTemplates"])
439
  }
440
+ tpl_name = stage1_info["missingTemplates"][0]
441
+ label = '{} (1/{})'.format(tpl_name, stage1_info["step2"]["totalNum"])
442
 
443
  stage1_info["state"] = "step2-selecting"
444
  # determine which button to display
 
567
  "totalNum" : len(stage1_info["missingTemplates"])
568
  }
569
  tpl_name = stage1_info["missingTemplates"][0]
570
+ label = '{} (1/{})'.format(tpl_name, stage1_info["step3"]["totalNum"])
571
 
572
  tpl_idx = channel_info["templateDict"][tpl_name]["index"]
573
  chkbox_value = stage1_info["mappingResults"][0]["newOrder"][tpl_idx]
 
581
  in_fillmode : gr.Dropdown(visible=False),
582
  fillmode_btn : gr.Button(visible=False),
583
  chkbox_group : gr.CheckboxGroup(choices=channel_info["inputOrder"],
584
+ value=chkbox_value, label=label, visible=True),
585
  next_btn : gr.Button(visible=True)}
586
  else:
587
  yield {stage1_json : stage1_info,
 
589
  in_fillmode : gr.Dropdown(visible=False),
590
  fillmode_btn : gr.Button(visible=False),
591
  chkbox_group : gr.CheckboxGroup(choices=channel_info["inputOrder"],
592
+ value=chkbox_value, label=label, visible=True),
593
  step3_btn : gr.Button(visible=True)}
594
 
595
  # =======================================step3-2========================================
 
690
  stage1_info["unassignedInputs"] = app_utils.get_unassigned_inputs(channel_info["inputOrder"], channel_info["inputDict"])
691
 
692
  tpl_name = stage1_info["missingTemplates"][step2["count"]-1]
693
+ label = '{} ({}/{})'.format(tpl_name, step2["count"], step2["totalNum"])
694
 
695
  stage1_info["step2"] = step2
696
  # determine which button to display
 
698
  return {stage1_json : stage1_info,
699
  channel_json : channel_info,
700
  radio_group : gr.Radio(choices=stage1_info["unassignedInputs"],
701
+ value=[], label=label),
702
  step2_btn : gr.Button(visible=False),
703
  next_btn : gr.Button(visible=True)}
704
  else:
705
  return {stage1_json : stage1_info,
706
  channel_json : channel_info,
707
  radio_group : gr.Radio(choices=stage1_info["unassignedInputs"],
708
+ value=[], label=label)}
709
  step2_btn.click(
710
  fn = update_radio,
711
  inputs = [stage1_json, channel_json, radio_group],
 
734
  step3["count"] += 1
735
 
736
  tpl_name = stage1_info["missingTemplates"][step3["count"]-1]
737
+ label = '{} ({}/{})'.format(tpl_name, step3["count"], step3["totalNum"])
738
 
739
  tpl_idx = channel_info["templateDict"][tpl_name]["index"]
740
  chkbox_value = stage1_info["mappingResults"][0]["newOrder"][tpl_idx]
 
744
  # determine which button to display
745
  if step3["count"] == step3["totalNum"]:
746
  return {stage1_json : stage1_info,
747
+ chkbox_group : gr.CheckboxGroup(value=chkbox_value, label=label),
748
  step3_btn : gr.Button(visible=False),
749
  next_btn : gr.Button(visible=True)}
750
  else:
751
  return {stage1_json : stage1_info,
752
+ chkbox_group : gr.CheckboxGroup(value=chkbox_value, label=label)}
753
 
754
  fillmode_btn.click(
755
  fn = init_next_step,