yashm commited on
Commit
3ed37d1
·
verified ·
1 Parent(s): 2ca4411

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -45
app.py CHANGED
@@ -60,58 +60,42 @@ selected_template = templates[presentation_type]
60
 
61
  # Title slide configuration
62
  st.sidebar.header("Title Slide")
63
- title_slide_preset = st.sidebar.selectbox("Choose Title Slide Preset", ["Custom", "Preset 1", "Preset 2"])
64
- if title_slide_preset == "Custom":
65
- title_slide_info = {
66
- 'title': st.sidebar.text_input("Title", "Your Presentation Title"),
67
- 'subtitle': st.sidebar.text_input("Subtitle", "Your Name"),
68
- 'institution': st.sidebar.text_input("Institution", "Your Institution"),
69
- 'date': st.sidebar.text_input("Date", "Presentation Date")
70
- }
71
- else:
72
- # Add more presets as needed
73
- if title_slide_preset == "Preset 1":
74
- title_slide_info = {
75
- 'title': "Preset Title 1",
76
- 'subtitle': "Preset Subtitle 1",
77
- 'institution': "Preset Institution 1",
78
- 'date': "Preset Date 1"
79
- }
80
- elif title_slide_preset == "Preset 2":
81
- title_slide_info = {
82
- 'title': "Preset Title 2",
83
- 'subtitle': "Preset Subtitle 2",
84
- 'institution': "Preset Institution 2",
85
- 'date': "Preset Date 2"
86
- }
87
-
88
- # Main page for sections and subsections configuration
89
- st.title('Customize Your Presentation')
90
- sections = OrderedDict()
91
 
92
- # Existing template sections
93
- for section in selected_template:
94
- with st.expander(f"Section: {section['title']}"):
95
- subsections = OrderedDict()
96
- for content_title in section['content']:
97
- bullets = st.text_area(f"Subsection: {content_title} (Enter bullet points separated by newlines)", height=150).split('\n')
98
- subsections[content_title] = bullets
99
- sections[section['title']] = {'title': section['title'], 'subsections': subsections}
100
 
101
- # Option to add more sections
102
  if st.sidebar.button("Add More Section"):
103
  new_section_title = st.sidebar.text_input("New Section Title", "New Section")
104
- new_subsections = OrderedDict()
105
- num_subsections = st.sidebar.number_input("Number of Subsections", min_value=1, step=1)
106
- for i in range(num_subsections):
107
- subsection_title = st.sidebar.text_input(f"Subsection Title {i+1}", f"New Subsection {i+1}")
108
- bullet_points = st.sidebar.text_area(f"Bullet Points for {subsection_title}", height=100).split('\n')
109
- new_subsections[subsection_title] = bullet_points
110
- sections[new_section_title] = {'title': new_section_title, 'subsections': new_subsections}
 
 
 
 
 
 
 
 
 
111
 
112
  # Generate and download presentation
113
  if st.button('Generate Presentation'):
114
- file_path = create_presentation(title_slide_info, sections)
115
  with open(file_path, "rb") as file:
116
  st.download_button(
117
  label="Download Presentation",
 
60
 
61
  # Title slide configuration
62
  st.sidebar.header("Title Slide")
63
+ title_slide_info = {
64
+ 'title': st.sidebar.text_input("Title", "Your Presentation Title"),
65
+ 'subtitle': st.sidebar.text_input("Subtitle", "Your Name"),
66
+ 'institution': st.sidebar.text_input("Institution", "Your Institution"),
67
+ 'date': st.sidebar.text_input("Date", "Presentation Date")
68
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
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
 
96
  # Generate and download presentation
97
  if st.button('Generate Presentation'):
98
+ file_path = create_presentation(title_slide_info, st.session_state.sections)
99
  with open(file_path, "rb") as file:
100
  st.download_button(
101
  label="Download Presentation",