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 |
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 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