Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,6 +70,7 @@ def generate_presentation_content(topic, client, max_retries=3):
|
|
| 70 |
def create_powerpoint(slides, template_path):
|
| 71 |
prs = Presentation(template_path)
|
| 72 |
|
|
|
|
| 73 |
for slide_data in slides:
|
| 74 |
slide = prs.slides.add_slide(prs.slide_layouts[1])
|
| 75 |
|
|
@@ -91,6 +92,26 @@ def create_powerpoint(slides, template_path):
|
|
| 91 |
tf = txBox.text_frame
|
| 92 |
tf.text = slide_data['content']
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
pptx_buffer = io.BytesIO()
|
| 95 |
prs.save(pptx_buffer)
|
| 96 |
pptx_buffer.seek(0)
|
|
@@ -142,4 +163,4 @@ def main():
|
|
| 142 |
st.warning("Por favor, ingrese un tema para la presentación.")
|
| 143 |
|
| 144 |
if __name__ == "__main__":
|
| 145 |
-
main()
|
|
|
|
| 70 |
def create_powerpoint(slides, template_path):
|
| 71 |
prs = Presentation(template_path)
|
| 72 |
|
| 73 |
+
# Agregar diapositivas generadas
|
| 74 |
for slide_data in slides:
|
| 75 |
slide = prs.slides.add_slide(prs.slide_layouts[1])
|
| 76 |
|
|
|
|
| 92 |
tf = txBox.text_frame
|
| 93 |
tf.text = slide_data['content']
|
| 94 |
|
| 95 |
+
# Agregar una diapositiva final con "Gracias"
|
| 96 |
+
slide = prs.slides.add_slide(prs.slide_layouts[1])
|
| 97 |
+
title_shape = slide.shapes.title
|
| 98 |
+
content_shape = slide.placeholders[1] if len(slide.placeholders) > 1 else None
|
| 99 |
+
|
| 100 |
+
if title_shape:
|
| 101 |
+
title_shape.text = "Gracias"
|
| 102 |
+
|
| 103 |
+
if content_shape:
|
| 104 |
+
content_shape.text = ""
|
| 105 |
+
else:
|
| 106 |
+
# Si no hay un placeholder para el contenido, añadimos un cuadro de texto
|
| 107 |
+
left = Inches(0.5)
|
| 108 |
+
top = Inches(1.5)
|
| 109 |
+
width = Inches(9)
|
| 110 |
+
height = Inches(5)
|
| 111 |
+
txBox = slide.shapes.add_textbox(left, top, width, height)
|
| 112 |
+
tf = txBox.text_frame
|
| 113 |
+
tf.text = ""
|
| 114 |
+
|
| 115 |
pptx_buffer = io.BytesIO()
|
| 116 |
prs.save(pptx_buffer)
|
| 117 |
pptx_buffer.seek(0)
|
|
|
|
| 163 |
st.warning("Por favor, ingrese un tema para la presentación.")
|
| 164 |
|
| 165 |
if __name__ == "__main__":
|
| 166 |
+
main()
|