Untitled
unknown
plain_text
3 months ago
2.3 kB
7
Indexable
# Create PPT with actual images (using placeholder solid shapes since no internet access for real images)
from pptx import Presentation
from pptx.util import Inches
from pptx.enum.shapes import MSO_SHAPE
prs = Presentation()
def add_slide(title, items):
slide_layout = prs.slide_layouts[5]
slide = prs.slides.add_slide(slide_layout)
# Title
title_box = slide.shapes.add_textbox(Inches(0.5), Inches(0.2), Inches(9), Inches(0.6))
title_box.text_frame.text = title
# positions for 4 sections
positions = [
(0.5,1), (5,1),
(0.5,3.5), (5,3.5)
]
for i,(word,definition) in enumerate(items):
left,top = positions[i]
# text box
tb = slide.shapes.add_textbox(Inches(left), Inches(top), Inches(4), Inches(1))
tf = tb.text_frame
p=tf.paragraphs[0]
p.text = word
p.font.bold = True
p2=tf.add_paragraph()
p2.text = definition
# image placeholder (colored box)
shape = slide.shapes.add_shape(
MSO_SHAPE.RECTANGLE,
Inches(left),
Inches(top+1.2),
Inches(2),
Inches(1.2)
)
shape.text_frame.text = "Image"
slides = [
("Etapas 1",[("la adolescencia","adolescence"),
("la edad","age"),
("el estado civil","marital status"),
("las etapas de la vida","stages of life")]),
("Etapas 2",[("la juventud","youth"),
("la madurez","middle age"),
("la muerte","death"),
("el nacimiento","birth")]),
("Etapas 3",[("la niñez","childhood"),
("la vejez","old age"),
("cambiar","to change"),
("graduarse","to graduate")]),
("Etapas 4",[("jubilarse","to retire"),
("nacer","to be born"),
("",""),
("","")]),
("Adicionales",[("la alegría","happiness"),
("el beso","kiss"),
("conmigo","with me"),
("contigo","with you")]),
("Expresiones 1",[("entregar","deliver"),
("enviar","send"),
("eras verde","was green"),
("las flores","flowers")]),
("Expresiones 2",[("el pedido","order"),
("el pincho","appetizer"),
("solo","only/alone"),
("tropezarse","run into")]),
("Expresiones 3",[("el globo","balloon"),
("juego de las sillas","musical chairs"),
("mensajero","messenger"),
("","")])
]
for t,i in slides:
add_slide(t,i)
file_path="/mnt/data/spanish_slides_with_images.pptx"
prs.save(file_path)
file_pathEditor is loading...
Leave a Comment