brickfrog commited on
Commit
6c77082
·
verified ·
1 Parent(s): d09f6aa

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. ankigen_core/ui_logic.py +19 -26
ankigen_core/ui_logic.py CHANGED
@@ -23,32 +23,25 @@ def update_mode_visibility(
23
  text_val = current_text if is_text else ""
24
  url_val = current_url if is_web else ""
25
 
26
- # Return a dictionary mapping component instances (which will be in app.py scope)
27
- # to their updated configurations using gr.update()
28
- # Keys here are placeholders; they need to match the actual Gradio components passed in the outputs list
29
- # when this function is used as an event handler in app.py.
30
- return {
31
- # Visibility updates for mode-specific groups
32
- "subject_mode_group": gr.update(visible=is_subject),
33
- "path_mode_group": gr.update(visible=is_path),
34
- "text_mode_group": gr.update(visible=is_text),
35
- "web_mode_group": gr.update(visible=is_web),
36
- # Visibility updates for output areas
37
- "path_results_group": gr.update(visible=is_path),
38
- "cards_output_group": gr.update(visible=is_subject or is_text or is_web),
39
- # Value updates for inputs (clear if mode changes)
40
- "subject_textbox": gr.update(value=subject_val),
41
- "description_textbox": gr.update(value=description_val),
42
- "source_text_textbox": gr.update(value=text_val),
43
- "url_textbox": gr.update(value=url_val),
44
- # Clear previous results/outputs
45
- "output_dataframe": gr.update(value=None),
46
- "subjects_dataframe": gr.update(value=None),
47
- "learning_order_markdown": gr.update(value=""),
48
- "projects_markdown": gr.update(value=""),
49
- "progress_html": gr.update(value="", visible=False),
50
- "total_cards_number": gr.update(value=0, visible=False),
51
- }
52
 
53
 
54
  def use_selected_subjects(subjects_df: pd.DataFrame | None):
 
23
  text_val = current_text if is_text else ""
24
  url_val = current_url if is_web else ""
25
 
26
+ # Return a tuple of gr.update() calls in the order expected by app.py
27
+ return (
28
+ gr.update(visible=is_subject),
29
+ gr.update(visible=is_path),
30
+ gr.update(visible=is_text),
31
+ gr.update(visible=is_web),
32
+ gr.update(visible=is_path),
33
+ gr.update(visible=is_subject or is_text or is_web),
34
+ gr.update(value=subject_val),
35
+ gr.update(value=description_val),
36
+ gr.update(value=text_val),
37
+ gr.update(value=url_val),
38
+ gr.update(value=None),
39
+ gr.update(value=None),
40
+ gr.update(value=""),
41
+ gr.update(value=""),
42
+ gr.update(value="", visible=False),
43
+ gr.update(value=0, visible=False),
44
+ )
 
 
 
 
 
 
 
45
 
46
 
47
  def use_selected_subjects(subjects_df: pd.DataFrame | None):