yashm commited on
Commit
633f6cc
·
verified ·
1 Parent(s): 3ed37d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -70,26 +70,37 @@ title_slide_info = {
70
  # Maintain session state for dynamically added sections
71
  if 'sections' not in st.session_state:
72
  st.session_state.sections = OrderedDict()
 
73
  for section in selected_template:
74
  st.session_state.sections[section['title']] = OrderedDict((content, []) for content in section['content'])
75
 
76
  # Option to add more sections dynamically
77
  if st.sidebar.button("Add More Section"):
78
- new_section_title = st.sidebar.text_input("New Section Title", "New Section")
79
- if new_section_title and new_section_title not in st.session_state.sections:
80
- st.session_state.sections[new_section_title] = OrderedDict()
81
- st.session_state.sections[new_section_title]["New Subsection"] = []
82
 
83
  # Main page for sections and subsections configuration
84
  st.title('Customize Your Presentation')
85
 
86
- for section_title, subsections in st.session_state.sections.items():
87
  with st.expander(f"Section: {section_title}"):
88
- for subsection_title, bullet_points in subsections.items():
89
- bullets = st.text_area(f"Subsection: {subsection_title} (Enter bullet points separated by newlines)", value="\n".join(bullet_points), height=150).split('\n')
 
 
 
 
 
 
 
 
 
90
  st.session_state.sections[section_title][subsection_title] = bullets
91
- if st.button(f"Add Subsection to {section_title}"):
92
- new_subsection_title = st.text_input(f"New Subsection Title for {section_title}", "New Subsection")
 
 
93
  if new_subsection_title and new_subsection_title not in st.session_state.sections[section_title]:
94
  st.session_state.sections[section_title][new_subsection_title] = []
95
 
 
70
  # Maintain session state for dynamically added sections
71
  if 'sections' not in st.session_state:
72
  st.session_state.sections = OrderedDict()
73
+ st.session_state.section_counter = 1 # Counter for unique section names
74
  for section in selected_template:
75
  st.session_state.sections[section['title']] = OrderedDict((content, []) for content in section['content'])
76
 
77
  # Option to add more sections dynamically
78
  if st.sidebar.button("Add More Section"):
79
+ new_section_title = f"New Section {st.session_state.section_counter}"
80
+ st.session_state.sections[new_section_title] = OrderedDict({"New Subsection": []})
81
+ st.session_state.section_counter += 1
 
82
 
83
  # Main page for sections and subsections configuration
84
  st.title('Customize Your Presentation')
85
 
86
+ for section_title, subsections in list(st.session_state.sections.items()):
87
  with st.expander(f"Section: {section_title}"):
88
+ # Edit section title
89
+ new_section_title = st.text_input(f"Edit Section Title:", value=section_title, key=f"section_title_{section_title}")
90
+ if new_section_title != section_title:
91
+ st.session_state.sections[new_section_title] = st.session_state.sections.pop(section_title)
92
+ section_title = new_section_title
93
+
94
+ for subsection_title, bullet_points in list(subsections.items()):
95
+ bullets = st.text_area(f"Subsection: {subsection_title} (Enter bullet points separated by newlines)",
96
+ value="\n".join(bullet_points),
97
+ height=150,
98
+ key=f"{section_title}_{subsection_title}").split('\n')
99
  st.session_state.sections[section_title][subsection_title] = bullets
100
+
101
+ # Add new subsection to the current section
102
+ if st.button(f"Add Subsection to {section_title}", key=f"add_subsection_{section_title}"):
103
+ new_subsection_title = st.text_input(f"New Subsection Title for {section_title}", "New Subsection", key=f"new_subsection_{section_title}")
104
  if new_subsection_title and new_subsection_title not in st.session_state.sections[section_title]:
105
  st.session_state.sections[section_title][new_subsection_title] = []
106