import streamlit as st from pptx import Presentation from pptx.util import Inches import requests from io import BytesIO # App Configuration st.set_page_config(page_title="Alphabet PPT Maker", page_icon="📊", layout="centered") st.title("📊 Alphabet PPT Creator for Kids") # Complete Alphabet Data with Pixabay Image URLs alphabets = { "A": {"desc": "Apple, Ant, Airplane", "images": [ "https://cdn.pixabay.com/photo/2015/03/26/09/40/apple-690342_960_720.jpg", "https://cdn.pixabay.com/photo/2013/07/12/17/39/ant-152539_960_720.png", "https://cdn.pixabay.com/photo/2015/03/26/10/10/plane-690402_960_720.jpg" ]}, "B": {"desc": "Ball, Banana, Butterfly", "images": [ "https://cdn.pixabay.com/photo/2016/03/31/19/57/football-1297357_960_720.png", "https://cdn.pixabay.com/photo/2014/10/23/18/05/banana-500067_960_720.jpg", "https://cdn.pixabay.com/photo/2016/04/24/22/36/butterfly-1359924_960_720.jpg" ]}, "C": {"desc": "Cat, Car, Cake", "images": [ "https://cdn.pixabay.com/photo/2017/11/09/21/41/cat-2934720_960_720.jpg", "https://cdn.pixabay.com/photo/2015/01/19/13/51/car-604019_960_720.jpg", "https://cdn.pixabay.com/photo/2017/08/06/07/50/birthday-cake-2594134_960_720.jpg" ]}, "D": {"desc": "Dog, Duck, Drum", "images": [ "https://cdn.pixabay.com/photo/2016/02/19/10/16/dog-1209984_960_720.jpg", "https://cdn.pixabay.com/photo/2016/04/07/11/10/duck-1312774_960_720.jpg", "https://cdn.pixabay.com/photo/2015/10/12/14/57/drum-984039_960_720.jpg" ]}, "E": {"desc": "Elephant, Egg, Eagle", "images": [ "https://cdn.pixabay.com/photo/2014/05/04/11/28/elephant-337658_960_720.jpg", "https://cdn.pixabay.com/photo/2016/02/24/20/50/eggs-1222043_960_720.jpg", "https://cdn.pixabay.com/photo/2016/02/25/20/36/eagle-1223405_960_720.jpg" ]}, "F": {"desc": "Fish, Frog, Flower", "images": [ "https://cdn.pixabay.com/photo/2017/03/27/13/36/fish-2172623_960_720.jpg", "https://cdn.pixabay.com/photo/2017/11/24/23/41/frog-2974588_960_720.jpg", "https://cdn.pixabay.com/photo/2015/04/19/08/33/flower-729513_960_720.jpg" ]}, "G": {"desc": "Goat, Giraffe, Grapes", "images": [ "https://cdn.pixabay.com/photo/2017/01/31/21/23/goat-2026224_960_720.jpg", "https://cdn.pixabay.com/photo/2018/06/24/10/41/giraffe-3492023_960_720.jpg", "https://cdn.pixabay.com/photo/2018/07/22/19/34/grapes-3550733_960_720.jpg" ]}, "H": {"desc": "House, Horse, Hat", "images": [ "https://cdn.pixabay.com/photo/2017/02/06/10/32/house-2044802_960_720.jpg", "https://cdn.pixabay.com/photo/2015/04/05/02/37/horse-706748_960_720.jpg", "https://cdn.pixabay.com/photo/2016/11/18/17/20/cowboy-1836018_960_720.jpg" ]}, "I": {"desc": "Ice, Iguana, Igloo", "images": [ "https://cdn.pixabay.com/photo/2015/08/05/00/23/ice-875822_960_720.jpg", "https://cdn.pixabay.com/photo/2018/04/22/15/25/iguana-3345161_960_720.jpg", "https://cdn.pixabay.com/photo/2014/10/12/22/46/igloo-486708_960_720.jpg" ]}, "Z": {"desc": "Zebra, Zoo, Zipper", "images": [ "https://cdn.pixabay.com/photo/2018/03/13/11/45/zebra-3227383_960_720.jpg", "https://cdn.pixabay.com/photo/2017/05/24/13/36/zoo-2331489_960_720.jpg", "https://cdn.pixabay.com/photo/2016/03/31/15/09/zipper-1295503_960_720.jpg" ]} } # Function to Create PPT def create_ppt(): prs = Presentation() for letter, details in alphabets.items(): slide_layout = prs.slide_layouts[5] slide = prs.slides.add_slide(slide_layout) title = slide.shapes.title title.text = f"{letter} is for {details['desc']}" x_offset = 1 for img_url in details["images"]: try: response = requests.get(img_url, timeout=10) if response.status_code == 200: img_stream = BytesIO(response.content) slide.shapes.add_picture( img_stream, Inches(x_offset), Inches(1.5), width=Inches(2), height=Inches(2) ) x_offset += 2.5 else: st.error(f"Failed to load {img_url}") except Exception as e: st.error(f"Error loading image: {img_url} - {e}") ppt_file = "alphabet_presentation.pptx" prs.save(ppt_file) return ppt_file # Generate PPT Button if st.button("Generate Alphabet PPT 📊"): ppt_file = create_ppt() with open(ppt_file, "rb") as file: st.download_button( "📥 Download PPT", file, file_name=ppt_file, mime="application/vnd.openxmlformats-officedocument.presentationml.presentation" ) st.success("PPT Created Successfully! 🎉")