python-pptx-presentation

byOussama Baccara (ING. Oussama Baccara)

!pip install python-pptx requests Pillow -q import requests from io import BytesIO from pptx import Presentation from pptx.util import Inches, Pt from pptx.dml.color import RGBColor from pptx.enum.text import PP_ALIGN, MSO_ANCHOR from pptx.enum.shapes import MSO_SHAPE prs = Presentation() prs.slide_width = Inches(13.33) prs.slide_height = Inches(7.5) BG_DARK = RGBColor(0x0A, 0x19, 0x31) BLUE = RGBColor(0x18, 0x5A, 0xDB) CYAN = RGBColor(0x00, 0xD1, 0xFF) def add_bg(slide, color): fill = slide.background.fill fill.solid() fill.fore_color.rgb = color def add_title(slide, title, subtitle=""): box = slide.shapes.add_textbox(Inches(0.5), Inches(0.2), Inches(12.33), Inches(0.6)) box.text_frame.word_wrap=True p=box.text_frame.paragraphs[0]; p.text=title; p.font.size=Pt(26); p.font.bold=True p.font.color.rgb= RGBColor(255,255,255) if slide.background.fill.fore_color.rgb==BG_DARK else BG_DARK if subtitle: box2 = slide.shapes.add_textbox(Inches(0.5), Inches(0.85), Inches(12.33), Inches(0.4)) box2.text_frame.word_wrap=True p2=box2.text_frame.paragraphs[0]; p2.text=subtitle; p2.font.size=Pt(12); p2.font.color.rgb=CYAN def add_return(slide, target): shp = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(10.5), Inches(6.8), Inches(2.3), Inches(0.5)) shp.fill.solid(); shp.fill.fore_color.rgb=CYAN; shp.line.fill.background() shp.text_frame.paragraphs[0].text="↩ Retour au projet" shp.text_frame.paragraphs[0].alignment=PP_ALIGN.CENTER shp.text_frame.vertical_anchor=MSO_ANCHOR.MIDDLE shp.text_frame.paragraphs[0].font.size=Pt(11); shp.text_frame.paragraphs[0].font.bold=True shp.text_frame.paragraphs[0].font.color.rgb=BG_DARK shp.click_action.target_slide = target def get_img(url): try: r=requests.get(url, timeout=15, headers={\'User-Agent\':\'Mozilla/5.0\'}) return BytesIO(r.content) except: return None # VRAIES PHOTOS PRODUITS URLS = { "ombriere": "https://images.unsplash.com/photo-1509391366360-2e959784a276?w=1200&q=80", "byd": "https://images.unsplash.com/photo-1620714223084-8fcacc6dfd8d?w=800&q=80", "huawei": "https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?w=800&q=80", "salle": "https://images.unsplash.com/photo-1497366216548-37526070297c?w=1200&q=80", } # SLIDE 1 - Couverture s1 = prs.slides.add_slide(prs.slide_layouts[6]); add_bg(s1, BG_DARK) add_title(s1, "CEMIA DE DEMAIN", "Plateforme intégrée : Énergie Solaire | Intelligence Artificielle Locale | Fabrication Numérique") t=s1.shapes.add_textbox(Inches(0.5), Inches(3), Inches(12.33), Inches(1.2)) t.text_frame.word_wrap=True; t.text_frame.paragraphs[0].text="Construire un écosystème capable de produire, exploiter, actualiser et transmettre\nla connaissance technique et pédagogique aéronautique." t.text_frame.paragraphs[0].font.size=Pt(16); t.text_frame.paragraphs[0].font.color.rgb=RGBColor(255,255,255); t.text_frame.paragraphs[0].alignment=PP_ALIGN.CENTER # SLIDE 2 - ACCUEIL INTERACTIF s2 = prs.slides.add_slide(prs.slide_layouts[6]); add_bg(s2, RGBColor(242,244,247)) add_title(s2, "LE CEMIA DE DEMAIN - Visite Interactive", "Cliquez sur une zone pour découvrir le projet") targets={} for i in range(3,14): targets[i]=prs.slides.add_slide(prs.slide_layouts[6]) zones=[("☀️ OMBRIÈRE\nSOLAIRE",3),("🔋 BATTERIES BYD\n10 ANS + HUAWEI",4),("🧠 SALLE IA LOCALE\n12 PC + DGX Spark",5),("📚 BIBLIOTHÈQUE\nNUMÉRIQUE RAG",7),("🎓 FORMATION\nAUGMENTÉE",8),("⚙️ FABRICATION\n7 IMPRIMANTES + CNC",9),("🔐 SÉCURITÉ\nGLOBALE",10),("✈️ 6 SPÉCIALITÉS\nAÉRONAUTIQUES",11)] for idx,(lab,tgt) in enumerate(zones): r=idx//4; c=idx%4 shp=s2.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.5+c*3.2), Inches(1.8+r*1.8), Inches(3), Inches(1.4)) shp.fill.solid(); shp.fill.fore_color.rgb=RGBColor(255,255,255); shp.line.color.rgb=BLUE; shp.line.width=Pt(2) shp.text_frame.word_wrap=True; shp.text_frame.paragraphs[0].text=lab shp.text_frame.paragraphs[0].alignment=PP_ALIGN.CENTER; shp.text_frame.vertical_anchor=MSO_ANCHOR.MIDDLE shp.text_frame.paragraphs[0].font.size=Pt(11); shp.text_frame.paragraphs[0].font.bold=True; shp.text_frame.paragraphs[0].font.color.rgb=BG_DARK shp.click_action.target_slide=targets[tgt] for lab,tgt,y in [("🔗 CHAÎNE GLOBALE DU PROJET",12,5.6),("💡 POURQUOI CE PROJET ?",13,6.3)]: shp=s2.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(3.5), Inches(y), Inches(6.33), Inches(0.5)) shp.fill.solid(); shp.fill.fore_color.rgb=BLUE; shp.line.fill.background() shp.text_frame.paragraphs[0].text=lab; shp.text_frame.paragraphs[0].alignment=PP_ALIGN.CENTER; shp.text_frame.vertical_anchor=MSO_ANCHOR.MIDDLE shp.text_frame.paragraphs[0].font.size=Pt(11); shp.text_frame.paragraphs[0].font.bold=True; shp.text_frame.paragraphs[0].font.color.rgb=RGBColor(255,255,255) shp.click_action.target_slide=targets[tgt] # S3 - Ombrière s3=targets[3]; add_bg(s3, RGBColor(255,255,255)); add_title(s3, "1. OMBRIÈRE PHOTOVOLTAÏQUE", "Double fonction : Ombre + Production électrique") try: s3.shapes.add_picture(get_img(URLS["ombriere"]), Inches(0.5), Inches(1.6), Inches(6), Inches(4.2)) except: pass tx=s3.shapes.add_textbox(Inches(7), Inches(1.6), Inches(5.5), Inches(4.5)); tx.text_frame.word_wrap=True tx.text_frame.text="☀️ Panneaux → ⚡ Conversion → 🔋 Stockage BYD → 🧠 Salle IA\n\n• C\'est quoi ? Structure acier couvrant le parking.\n• Sert à quoi ? 1. Protéger les véhicules 2. Produire de l\'électricité verte.\n• Pourquoi ? Valorise le parking et alimente directement l\'IA." add_return(s3,s2) # S4 - BYD 10 ANS + HUAWEI s4=targets[4]; add_bg(s4, RGBColor(255,255,255)); add_title(s4, "2. COEUR ÉLECTRIQUE : BYD + HUAWEI", "Continuité absolue - Garantie 10 ans constructeur") for x, titre, modele, leg in [(0.5,"BATTERIE LITHIUM","BYD Battery-Box Premium\nHVS / HVM","Garantie 10 ans - Armoire blanche murale"),(3.8,"ONDULEUR HYBRIDE","Huawei SUN2000\n8-10KTL-M1","Hybride Solaire + STEG + Batterie")]: shp=s4.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(x), Inches(1.6), Inches(3), Inches(3.2)) shp.fill.solid(); shp.fill.fore_color.rgb=RGBColor(242,244,247); shp.line.color.rgb=BLUE t=s4.shapes.add_textbox(Inches(x), Inches(1.7), Inches(3), Inches(3)) t.text_frame.word_wrap=True; t.text_frame.paragraphs[0].text=f"{titre}\n{modele}\n\n{leg}\n\n[PHOTO RÉELLE HD]"; t.text_frame.paragraphs[0].font.size=Pt(9); t.text_frame.paragraphs[0].alignment=PP_ALIGN.CENTER tx=s4.shapes.add_textbox(Inches(7.2), Inches(1.6), Inches(5.3), Inches(4.2)); tx.text_frame.word_wrap=True tx.text_frame.text="FLUX D\'ÉNERGIE :\n☀️ Solaire + 🏢 STEG → [ONDULEUR HUAWEI] → 🧠 Salle IA\n\nSECOURS :\nSi coupure STEG → Bascule auto → 🔋 BYD → 🧠 IA PROTÉGÉE\n\n* Temps de basculement selon fiche technique officielle Huawei." add_return(s4,s2) # S5 - Salle IA s5=targets[5]; add_bg(s5, RGBColor(255,255,255)); add_title(s5, "3. SALLE IA LOCALE", "12 Postes + 2 Flagship + 1 DGX Spark compact [PAS un serveur rack]") for x,t1,t2 in [(0.5,"12x POSTES APPRENANTS","RTX 5060 Ti 16Go\n1 écran / poste"),(4.7,"2x STATIONS FLAGSHIP","Flagship 1: R9 9950X3D + RTX 5090 + 64Go\nFlagship 2: 128Go ECC + GPU Pro"),(8.9,"NVIDIA DGX SPARK","Boitier compact noir 15cm\nIA locale - Complémentaire stations")]: shp=s5.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(x), Inches(1.6), Inches(3.8), Inches(3.5)) shp.fill.solid(); shp.fill.fore_color.rgb=RGBColor(242,244,247); shp.line.color.rgb=BLUE t=s5.shapes.add_textbox(Inches(x+0.1), Inches(1.7), Inches(3.6), Inches(3.3)); t.text_frame.word_wrap=True t.text_frame.paragraphs[0].text=f"{t1}\n\n{t2}\n\n[PHOTO RÉELLE]"; t.text_frame.paragraphs[0].font.size=Pt(9); t.text_frame.paragraphs[0].alignment=PP_ALIGN.CENTER add_return(s5,s2) titres={7:("4. BIBLIOTHÈQUE NUMÉRIQUE + RAG","Programmes → Sources → Vérification → Indexation → RAG → IA"),8:("5. FORMATION AUGMENTÉE","Doc → IA → Cours / Slides / Vidéos / QCM / TP | Formateur = VALIDATEUR"),9:("6. FABRICATION NUMÉRIQUE","CAO → Simulation → FAO → G-code → Fabrication | 4 Résine + 3 FDM = 7 + CNC"),10:("7. SÉCURITÉ GLOBALE","📹 Caméras | 🚨 Alarme | 🔐 Badge | 🔥 Incendie | 🌡️ Environnement"),11:("8. LES 6 SPÉCIALITÉS AÉRONAUTIQUES","Ajusteur | Chaudronnerie | Composites | Traitement Surface | Câblage | CNC"),12:("9. CHAÎNE GLOBALE DU PROJET","☀️ Solaire → 🔋 Stockage → 🧠 IA → 📚 RAG → 🎓 Formation → 🧪 Simulation → 🏭 Fabrication → ✈️"),13:("POURQUOI CE PROJET ?","Construire un écosystème capable de produire, exploiter et transmettre la connaissance.")} for num,(t,st) in titres.items(): s=targets[num]; add_bg(s, BG_DARK if num==13 else RGBColor(255,255,255)); add_title(s,t,st) if num==13: box=s.shapes.add_textbox(Inches(0.5), Inches(2.5), Inches(12.33), Inches(3)) box.text_frame.word_wrap=True box.text_frame.paragraphs[0].text="✅ Compétences IA • ✅ Bibliothèque souveraine • ✅ Ressources modernes\n✅ Simulation • ✅ Fabrication numérique • ✅ Énergie solaire • ✅ Sécurité • ✅ Industrie 4.0" box.text_frame.paragraphs[0].font.size=Pt(14); box.text_frame.paragraphs[0].font.color.rgb=RGBColor(255,255,255); box.text_frame.paragraphs[0].alignment=PP_ALIGN.CENTER add_return(s,s2) prs.save(\'/tmp/CEMIA_Projet_Global_Interactif_16-9.pptx\') print("✅ Fichier généré !") try: from google.colab import files files.download(\'/tmp/CEMIA_Projet_Global_Interactif_16-9.pptx\') except: pass

LE CEMIA DE DEMAIN - Visite Interactive
LE CEMIA DE DEMAIN - Visite Interactive

Comments (0)

No comments yet. Be the first!

Architecture

No Services Diagrams Yet

Architecture diagrams will be automatically generated when the Project Manager creates tasks for your project.

LE CEMIA DE DEMAIN - Visite Interactive design preview
LE CEMIA DE DEMAIN - Visite Interactive: Open deck and view interactive hub
1. OMBRIÈRE PHOTOVOLTAÏQUE: Read dual-function explanation and energy flow
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
2. COEUR ÉLECTRIQUE : BYD + HUAWEI: Read product panels and backup path
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
3. SALLE IA LOCALE: Read workstation and DGX Spark specs
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
4. BIBLIOTHÈQUE NUMÉRIQUE + RAG: Read RAG pipeline steps
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
5. FORMATION AUGMENTÉE: Read augmented-training pipeline
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
6. FABRICATION NUMÉRIQUE: Read CAD-to-fabrication pipeline
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
7. SÉCURITÉ GLOBALE: Read five security domains
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
8. LES 6 SPÉCIALITÉS AÉRONAUTIQUES: Read six aeronautical specialties
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
9. CHAÎNE GLOBALE DU PROJET: Read eight-stage global chain
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
POURQUOI CE PROJET ?: Read rationale and outcome markers
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub after rationale
LE CEMIA DE DEMAIN - Visite Interactive: Navigate slides manually after broken link
LE CEMIA DE DEMAIN - Visite Interactive: End session or revisit a topic
LE CEMIA DE DEMAIN - Visite Interactive design preview
LE CEMIA DE DEMAIN - Visite Interactive: Open deck and view interactive hub
1. OMBRIÈRE PHOTOVOLTAÏQUE: Read dual-function explanation and energy flow
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
2. COEUR ÉLECTRIQUE : BYD + HUAWEI: Read product panels and backup path
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
3. SALLE IA LOCALE: Read workstation and DGX Spark specs
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
4. BIBLIOTHÈQUE NUMÉRIQUE + RAG: Read RAG pipeline steps
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
5. FORMATION AUGMENTÉE: Read augmented-training pipeline
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
6. FABRICATION NUMÉRIQUE: Read CAD-to-fabrication pipeline
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
7. SÉCURITÉ GLOBALE: Read five security domains
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
8. LES 6 SPÉCIALITÉS AÉRONAUTIQUES: Read six aeronautical specialties
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
9. CHAÎNE GLOBALE DU PROJET: Read eight-stage global chain
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub
POURQUOI CE PROJET ?: Read rationale and outcome markers
LE CEMIA DE DEMAIN - Visite Interactive: Return to hub after rationale
LE CEMIA DE DEMAIN - Visite Interactive: Navigate slides manually after broken link
LE CEMIA DE DEMAIN - Visite Interactive: End session or revisit a topic