yashm commited on
Commit
13a6efb
·
verified ·
1 Parent(s): c33529b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -90,7 +90,14 @@ def add_new_subsection(section_title):
90
  # Streamlit UI setup
91
  st.sidebar.title('Presentation Settings')
92
  presentation_type = st.sidebar.selectbox('Select Presentation Type', list(templates.keys()))
93
- selected_template = templates[presentation_type]
 
 
 
 
 
 
 
94
 
95
  # Title slide configuration with expander
96
  with st.sidebar.expander("Title Slide Options", expanded=False):
@@ -101,13 +108,6 @@ with st.sidebar.expander("Title Slide Options", expanded=False):
101
  'date': st.text_input("Date", "Presentation Date")
102
  }
103
 
104
- # Maintain session state for dynamically added sections
105
- if 'sections' not in st.session_state:
106
- st.session_state.sections = OrderedDict()
107
- st.session_state.section_counter = 1 # Counter for unique section names
108
- for section in selected_template:
109
- st.session_state.sections[section['title']] = OrderedDict((content, []) for content in section['content'])
110
-
111
  # Option to add more sections dynamically
112
  if st.sidebar.button("Add More Section"):
113
  add_new_section(st.session_state.section_counter)
 
90
  # Streamlit UI setup
91
  st.sidebar.title('Presentation Settings')
92
  presentation_type = st.sidebar.selectbox('Select Presentation Type', list(templates.keys()))
93
+
94
+ # Reset sections when a new presentation type is selected
95
+ if 'last_presentation_type' not in st.session_state or st.session_state.last_presentation_type != presentation_type:
96
+ st.session_state.sections = OrderedDict()
97
+ st.session_state.section_counter = 1 # Counter for unique section names
98
+ for section in templates[presentation_type]:
99
+ st.session_state.sections[section['title']] = OrderedDict((content, []) for content in section['content'])
100
+ st.session_state.last_presentation_type = presentation_type # Update the last selected type
101
 
102
  # Title slide configuration with expander
103
  with st.sidebar.expander("Title Slide Options", expanded=False):
 
108
  'date': st.text_input("Date", "Presentation Date")
109
  }
110
 
 
 
 
 
 
 
 
111
  # Option to add more sections dynamically
112
  if st.sidebar.button("Add More Section"):
113
  add_new_section(st.session_state.section_counter)