yashm commited on
Commit
35622fd
·
verified ·
1 Parent(s): ca039d5

Update app.py

Browse files

second correction

Files changed (1) hide show
  1. app.py +8 -22
app.py CHANGED
@@ -73,18 +73,13 @@ def create_presentation(title_slide_info, sections, theme_name):
73
  # Add content slides based on sections and subsections
74
  for section_title, section_info in sections.items():
75
  for subsection_title, bullet_points in section_info.items():
76
- slide_layout = prs.slide_layouts[1]
77
- slide = prs.slides.add_slide(slide_layout)
78
- title_placeholder = slide.shapes.title
79
- body_placeholder = slide.placeholders[1]
80
- title_placeholder.text = f"{section_title} - {subsection_title}"
81
-
82
- # Custom styling options
83
- for bullet in bullet_points:
84
- p = body_placeholder.text_frame.add_paragraph()
85
- p.text = bullet
86
- style_text(p, theme["font_size"], theme["color"])
87
-
88
  # Save the presentation
89
  filename = 'custom_presentation.pptx'
90
  prs.save(filename)
@@ -107,6 +102,7 @@ def add_slide_with_layout(prs, layout_index, title_text, content_points):
107
  for point in content_points:
108
  p = body_placeholder.text_frame.add_paragraph()
109
  p.text = point
 
110
 
111
  # Function to add image to a slide
112
  def add_image_to_slide(slide, image_path):
@@ -183,16 +179,6 @@ for section_title in st.session_state.sections:
183
 
184
  # Generate and download presentation
185
  if st.button('Generate Presentation'):
186
- prs = Presentation()
187
- for section_title, subsections in st.session_state.sections.items():
188
- for subsection_title, bullet_points in subsections.items():
189
- slide = add_slide_with_layout(prs, 1, f"{section_title} - {subsection_title}", bullet_points)
190
- if section_title in uploaded_images:
191
- image_path = os.path.join(os.getcwd(), uploaded_images[section_title].name)
192
- with open(image_path, "wb") as f:
193
- f.write(uploaded_images[section_title].getbuffer())
194
- add_image_to_slide(slide, image_path)
195
-
196
  file_path = create_presentation(title_slide_info, st.session_state.sections, theme_name)
197
  with open(file_path, "rb") as file:
198
  st.download_button(
 
73
  # Add content slides based on sections and subsections
74
  for section_title, section_info in sections.items():
75
  for subsection_title, bullet_points in section_info.items():
76
+ slide = add_slide_with_layout(prs, 1, f"{section_title} - {subsection_title}", bullet_points)
77
+ if section_title in uploaded_images:
78
+ image_path = os.path.join(os.getcwd(), uploaded_images[section_title].name)
79
+ with open(image_path, "wb") as f:
80
+ f.write(uploaded_images[section_title].getbuffer())
81
+ add_image_to_slide(slide, image_path)
82
+
 
 
 
 
 
83
  # Save the presentation
84
  filename = 'custom_presentation.pptx'
85
  prs.save(filename)
 
102
  for point in content_points:
103
  p = body_placeholder.text_frame.add_paragraph()
104
  p.text = point
105
+ return slide
106
 
107
  # Function to add image to a slide
108
  def add_image_to_slide(slide, image_path):
 
179
 
180
  # Generate and download presentation
181
  if st.button('Generate Presentation'):
 
 
 
 
 
 
 
 
 
 
182
  file_path = create_presentation(title_slide_info, st.session_state.sections, theme_name)
183
  with open(file_path, "rb") as file:
184
  st.download_button(