duongthienz commited on
Commit
a9f4fc2
·
verified ·
1 Parent(s): 4ed414e

Update left side bar content

Browse files
Files changed (1) hide show
  1. ui.py +26 -15
ui.py CHANGED
@@ -52,22 +52,31 @@ def render_chart(fig, tab, pdf_path, svg_path, pdf_name, svg_name, pdf_key, svg_
52
 
53
  def render_categories_sidebar(currFile, categorySelections, all_speakers_display,
54
  raw_to_display):
55
- """Render category multiselects, remove buttons, and Add category input."""
 
 
 
 
 
56
  for i, category in enumerate(st.session_state.categories):
57
  ms_key = f"multiselect_{category}"
58
  speakerSet = categorySelections[i]
59
  default_disp = [raw_to_display.get(sp, sp) for sp in speakerSet]
60
  if ms_key not in st.session_state:
61
  st.session_state[ms_key] = default_disp
 
 
 
 
 
 
 
62
  st.sidebar.multiselect(
63
  category, all_speakers_display,
64
  key=ms_key, on_change=updateCategoryOptions, args=(currFile,),
 
65
  )
66
- st.sidebar.button(
67
- f"Remove {category}", key=f"remove_{category}",
68
- on_click=removeCategory, args=(i,),
69
- )
70
- st.sidebar.text_input("Add Category", key="categoryInput", on_change=addCategory)
71
 
72
 
73
  # ---------------------------------------------------------------------------
@@ -75,13 +84,13 @@ def render_categories_sidebar(currFile, categorySelections, all_speakers_display
75
  # ---------------------------------------------------------------------------
76
 
77
  def render_rename_sidebar(currFile, speakerNames, all_speaker_tokens):
78
- """Render the full Rename Speakers sidebar section."""
79
  st.sidebar.divider()
80
- st.sidebar.subheader("Rename Speakers")
81
  st.sidebar.markdown(
82
  "<p style='font-size:0.85rem; color:gray; margin-bottom:2px;'>"
83
- "Assign a name and select which speaker labels (across all files) it applies to. "
84
- "Changes apply to all matched speakers instantly.</p>",
85
  unsafe_allow_html=True,
86
  )
87
 
@@ -97,16 +106,18 @@ def render_rename_sidebar(currFile, speakerNames, all_speaker_tokens):
97
  grkey = _global_rename_key(idx)
98
  if grkey not in st.session_state:
99
  st.session_state[grkey] = list(entry["speakers"])
100
- st.sidebar.markdown(f"**{entry['name']}**")
 
 
 
 
 
 
101
  st.sidebar.multiselect(
102
  f"Speakers for {entry['name']}", options=all_speaker_tokens,
103
  key=grkey, on_change=_on_grename_change, args=(idx,),
104
  label_visibility="collapsed",
105
  )
106
- st.sidebar.button(
107
- f"Remove '{entry['name']}'", key=f"remove_grename_{idx}",
108
- on_click=removeGlobalRename, args=(idx,),
109
- )
110
 
111
  st.sidebar.text_input(
112
  "Add rename", placeholder="e.g. John",
 
52
 
53
  def render_categories_sidebar(currFile, categorySelections, all_speakers_display,
54
  raw_to_display):
55
+ """Render category multiselects, remove buttons, and Add role input."""
56
+ st.sidebar.markdown(
57
+ "<p style='font-size:0.85rem; color:gray; margin-bottom:2px;'>"
58
+ "Create roles (instructor, students, etc.) and add speakers.</p>",
59
+ unsafe_allow_html=True,
60
+ )
61
  for i, category in enumerate(st.session_state.categories):
62
  ms_key = f"multiselect_{category}"
63
  speakerSet = categorySelections[i]
64
  default_disp = [raw_to_display.get(sp, sp) for sp in speakerSet]
65
  if ms_key not in st.session_state:
66
  st.session_state[ms_key] = default_disp
67
+ label_col, trash_col = st.sidebar.columns([5, 1])
68
+ label_col.markdown(f"**{category}**")
69
+ trash_col.button(
70
+ "🗑️", key=f"remove_{category}",
71
+ on_click=removeCategory, args=(i,),
72
+ help=f"Remove {category}",
73
+ )
74
  st.sidebar.multiselect(
75
  category, all_speakers_display,
76
  key=ms_key, on_change=updateCategoryOptions, args=(currFile,),
77
+ label_visibility="collapsed",
78
  )
79
+ st.sidebar.text_input("Add role", key="categoryInput", on_change=addCategory)
 
 
 
 
80
 
81
 
82
  # ---------------------------------------------------------------------------
 
84
  # ---------------------------------------------------------------------------
85
 
86
  def render_rename_sidebar(currFile, speakerNames, all_speaker_tokens):
87
+ """Render the full Rename Multiple Speakers sidebar section."""
88
  st.sidebar.divider()
89
+ st.sidebar.subheader("Rename Multiple Speakers")
90
  st.sidebar.markdown(
91
  "<p style='font-size:0.85rem; color:gray; margin-bottom:2px;'>"
92
+ "This option works best for renaming multiple speakers across multiple files. "
93
+ "For a simple rename for a single file, use the Rename Speaker tab in the center.</p>",
94
  unsafe_allow_html=True,
95
  )
96
 
 
106
  grkey = _global_rename_key(idx)
107
  if grkey not in st.session_state:
108
  st.session_state[grkey] = list(entry["speakers"])
109
+ label_col, trash_col = st.sidebar.columns([5, 1])
110
+ label_col.markdown(f"**{entry['name']}**")
111
+ trash_col.button(
112
+ "🗑️", key=f"remove_grename_{idx}",
113
+ on_click=removeGlobalRename, args=(idx,),
114
+ help=f"Remove '{entry['name']}'",
115
+ )
116
  st.sidebar.multiselect(
117
  f"Speakers for {entry['name']}", options=all_speaker_tokens,
118
  key=grkey, on_change=_on_grename_change, args=(idx,),
119
  label_visibility="collapsed",
120
  )
 
 
 
 
121
 
122
  st.sidebar.text_input(
123
  "Add rename", placeholder="e.g. John",