Using code for a powerpoint is a useful approach to have chatgpt and other LLMs create powerpoint slides from documents or a textual description.
pip install -r requirements.txt
python make_powerpoint.py| from pptx import Presentation | |
| from pptx.util import Inches | |
| from pptx.enum.chart import XL_CHART_TYPE | |
| # Create a presentation object | |
| prs = Presentation() | |
| # Add a title slide | |
| slide_layout = prs.slide_layouts[0] # 0 is the layout for the title slide | |
| slide = prs.slides.add_slide(slide_layout) | |
| title = slide.shapes.title | |
| subtitle = slide.placeholders[1] | |
| title.text = "Welcome to the Presentation" | |
| subtitle.text = "This presentation contains text, a table, and a chart." | |
| # Add a slide with a title and content | |
| slide_layout = prs.slide_layouts[1] # 1 is the layout for title and content | |
| slide = prs.slides.add_slide(slide_layout) | |
| title = slide.shapes.title | |
| content = slide.placeholders[1] | |
| title.text = "Agenda" | |
| content.text = "1. Introduction\n2. Main Content\n3. Conclusion" | |
| # Add a slide with a table | |
| slide_layout = prs.slide_layouts[5] # 5 is the layout for title and content | |
| slide = prs.slides.add_slide(slide_layout) | |
| title = slide.shapes.title | |
| title.text = "Data Table" | |
| # Define table dimensions | |
| rows = 3 | |
| cols = 4 | |
| left = Inches(2) | |
| top = Inches(2) | |
| width = Inches(6) | |
| height = Inches(1.5) | |
| # Add table | |
| table = slide.shapes.add_table(rows, cols, left, top, width, height).table | |
| # Set column headings | |
| table.columns[0].width = Inches(1.5) | |
| table.columns[1].width = Inches(1.5) | |
| table.columns[2].width = Inches(1.5) | |
| table.columns[3].width = Inches(1.5) | |
| table.cell(0, 0).text = 'Header 1' | |
| table.cell(0, 1).text = 'Header 2' | |
| table.cell(0, 2).text = 'Header 3' | |
| table.cell(0, 3).text = 'Header 4' | |
| # Add data to the table | |
| table.cell(1, 0).text = 'Data 1' | |
| table.cell(1, 1).text = 'Data 2' | |
| table.cell(1, 2).text = 'Data 3' | |
| table.cell(1, 3).text = 'Data 4' | |
| table.cell(2, 0).text = 'Data 5' | |
| table.cell(2, 1).text = 'Data 6' | |
| table.cell(2, 2).text = 'Data 7' | |
| table.cell(2, 3).text = 'Data 8' | |
| prs.save('combined_presentation.pptx') |
| python-pptx |
Muito obrigado, @andreinhafcg!
from pptx import Presentation
from pptx.util import Inches, Pt
prs = Presentation()
prs.slide_width = Inches(13.33)
prs.slide_height = Inches(7.5)
slide = prs.slides.add_slide(prs.slide_layouts[6])
title_box = slide.shapes.add_textbox(Inches(0.5), Inches(0.2), Inches(12), Inches(1))
title_frame = title_box.text_frame
title_frame.text = "Gut Microbiota Profile in Type 2 Diabetes: With vs. Without Metformin"
title_frame.paragraphs[0].font.size = Pt(32)
title_frame.paragraphs[0].font.bold = True
left_box = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(6), Inches(5))
left_frame = left_box.text_frame
left_frame.word_wrap = True
p1 = left_frame.add_paragraph()
p1.text = (
"❌ Without Metformin:\n"
"- Low microbial diversity\n"
"- ↑ Clostridiaceae\n"
"- ↑ A type of Prevotella\n"
"- ↓ Enterococcus casseliflavus\n\n"
"Microbiota less beneficial"
)
p1.font.size = Pt(20)
right_box = slide.shapes.add_textbox(Inches(6.8), Inches(1.5), Inches(6), Inches(5))
right_frame = right_box.text_frame
right_frame.word_wrap = True
p2 = right_frame.add_paragraph()
p2.text = (
"✅ With Metformin:\n"
"- Increased Akkermansia muciniphila (mucin-degrading)\n"
"- ↑ SCFA-producing bacteria:\n"
" • Butyrivibrio\n"
" • Bifidobacterium bifidum\n"
" • Megasphaera\n"
" • Prevotella\n"
"- SCFA Benefits:\n"
" • Improved insulin sensitivity\n"
" • Reduced inflammation\n"
" • Energy for colon cells"
)
p2.font.size = Pt(20)
prs.save("Gut_Microbiota_Metformin_Infographic.pptx")
from pptx import Presentation from pptx.util import Inches, Pt from pptx.dml.color import RGBColor
Create presentation
prs = Presentation()
Title Slide
title_slide_layout = prs.slide_layouts[0] slide = prs.slides.add_slide(title_slide_layout) title = slide.shapes.title title.text = "Iron Deficiency Anemia" subtitle = slide.placeholders[1] subtitle.text = "Lecture for MBBS Students"
Function to add a slide with bullet points
def add_bullet_slide(title_text, bullet_points): slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(slide_layout) title = slide.shapes.title title.text = title_text content = slide.placeholders[1] tf = content.text_frame tf.clear() for point in bullet_points: p = tf.add_paragraph() p.text = point p.font.size = Pt(20)
Overview
add_bullet_slide("Overview", [ "Most common cause of anemia worldwide", "Microcytic, hypochromic red cells", "Common in children, women of reproductive age, elderly", "Hb <130 g/L (men), <120 g/L (women)" ])
Etiology
add_bullet_slide("Etiology", [ "Blood loss: GI bleeding, menorrhagia, NSAIDs", "Reduced intake: poor diet, vegetarian/vegan", "Malabsorption: celiac disease, gastrectomy", "Increased demand: pregnancy, growth spurts" ])
Clinical Features
add_bullet_slide("Clinical Features", [ "Symptoms: fatigue, dyspnoea, pica, headache", "Signs: pallor, angular cheilitis, koilonychia, glossitis", "Severe: tachycardia, murmurs, heart failure" ])
Pathophysiology
add_bullet_slide("Pathophysiology", [ "Loss of iron → reduced Hb synthesis", "Stages: 1) Depleted ferritin, 2) Impaired erythropoiesis, 3) Microcytosis & hypochromia", "Peripheral smear: microcytic, hypochromic, anisopoikilocytosis", "Bone marrow: absent iron stores (Prussian blue stain)" ])
Diagnosis
add_bullet_slide("Diagnosis", [ "CBC: low Hb, MCV, MCH, high RDW", "Iron studies: low ferritin, low transferrin saturation, high TIBC", "Peripheral smear: microcytic, hypochromic, elliptocytes", "Stages: ferritin ↓ → impaired erythropoiesis → microcytosis" ])
Management
add_bullet_slide("Management", [ "Treat underlying cause", "Oral iron: ferrous sulphate 200 mg/d × 3 months post-Hb
from pptx import Presentation
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[0])
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = "Larangan ASN dan Implementasinya"
subtitle.text = "Dibuat oleh ChatGPT | 2025"
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = "Pendahuluan"
slide.placeholders[1].text = (
"ASN memiliki peran strategis dalam penyelenggaraan pemerintahan dan pelayanan publik. "
"Untuk menjaga integritas dan profesionalisme birokrasi, berbagai larangan diterapkan "
"agar ASN tidak terlibat dalam politik praktis, penyalahgunaan wewenang, atau konflik kepentingan."
)
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = "Asas-asas Penyelenggaraan ASN"
slide.placeholders[1].text = (
"Berdasarkan UU
from pptx import Presentation
Criação da apresentação
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[0])
slide.shapes.title.text = "O Papel das Organizações Não Governamentais na Promoção da Saúde"
slide.placeholders[1].text = "Nome do aluno\nDisciplina\nProfessor\nData"
Outros slides resumidos
slides_info = [
("Introdução", "ONG’s são entidades sem fins lucrativos com papel essencial na saúde.\nPromovem prevenção, apoio e sensibilização."),
("O Papel das ONG’s", "- Prevenção\n- Apoio direto\n- Complemento aos serviços públicos"),
("Exemplos de ONG’s", "HIV/SIDA: Abraço\nCancro: Liga Contra o Cancro\nSaúde Mental: Encontrar+se\nDoenças Raras: Raríssimas\nDependências: APDES"),
("Associação APFQ", "Fundada em 1997\nMissão: apoiar doentes com Fibrose Quística\nApoio psicológico e social\nCampanhas e testemunhos"),
("Conclusão", "ONG’s são fundamentais para a promoção da saúde e justiça social."),
("Bibliografia", "https://www.apfq.pt\nhttps://abraco.pt\nhttps://ligacontracancro.pt\nhttps://rarissimas.pt")
]
for title, content in slides_info:
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = title
content_frame = slide.placeholders[1].text_frame
for line in content.split('\n'):
p = content_frame.add_paragraph()
p.text = line
prs.save("Trabalho_ONG_Saude_APFQ.pptx")