Woziii commited on
Commit
75a54e6
·
verified ·
1 Parent(s): ad0fea3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -65,7 +65,7 @@ with gr.Blocks() as demo:
65
  with gr.Box():
66
  gr.Markdown("### ✍️ Gestion des Sections")
67
 
68
- sections = gr.State(value=[]) # État pour stocker les sections
69
 
70
  def update_section_list(sections):
71
  return [gr.Textbox(label=f"Nom : {s['name']}", value=s["text"], lines=2) for s in sections]
@@ -80,16 +80,16 @@ with gr.Blocks() as demo:
80
  sections.append(section)
81
  return sections, update_section_list(sections)
82
 
83
- add_section_btn.click(add_section, inputs=[sections], outputs=[sections, sections_list])
84
 
85
  remove_section_btn = gr.Button("- Supprimer la dernière Section ➖")
86
 
87
  def remove_section(sections):
88
- if sections:
89
  sections.pop()
90
  return sections, update_section_list(sections)
91
 
92
- remove_section_btn.click(remove_section, inputs=[sections], outputs=[sections, sections_list])
93
 
94
  with gr.Box():
95
  gr.Markdown("### 🎧 Génération des Audios")
 
65
  with gr.Box():
66
  gr.Markdown("### ✍️ Gestion des Sections")
67
 
68
+ sections = gr.State(value=[{"name": "Section_1", "text": ""}]) # Une section par défaut
69
 
70
  def update_section_list(sections):
71
  return [gr.Textbox(label=f"Nom : {s['name']}", value=s["text"], lines=2) for s in sections]
 
80
  sections.append(section)
81
  return sections, update_section_list(sections)
82
 
83
+ add_section_btn.click(add_section, inputs=[sections], outputs=[sections])
84
 
85
  remove_section_btn = gr.Button("- Supprimer la dernière Section ➖")
86
 
87
  def remove_section(sections):
88
+ if len(sections) > 1: # Ne pas supprimer si c'est la seule section
89
  sections.pop()
90
  return sections, update_section_list(sections)
91
 
92
+ remove_section_btn.click(remove_section, inputs=[sections], outputs=[sections])
93
 
94
  with gr.Box():
95
  gr.Markdown("### 🎧 Génération des Audios")