yashm commited on
Commit
1f4eddf
·
verified ·
1 Parent(s): 113765d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -0
app.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from pptx import Presentation
3
+ from pptx.util import Inches
4
+ import os
5
+
6
+ # Function to create PowerPoint presentation
7
+ def create_presentation():
8
+ prs = Presentation()
9
+
10
+ # Add a title slide
11
+ title_slide_layout = prs.slide_layouts[0] # 0 is for title slide
12
+ title_slide = prs.slides.add_slide(title_slide_layout)
13
+ title = title_slide.shapes.title
14
+ subtitle = title_slide.placeholders[1]
15
+ title.text = "Research Presentation Title"
16
+ subtitle.text = "Your Name\nYour Institution\nDate"
17
+
18
+ # Define the sections with titles and contents
19
+ sections = [
20
+ {"title": "Introduction", "content": ["Background", "Problem Statement", "Purpose"]},
21
+ {"title": "Literature Review", "content": ["Previous Studies", "Key Theories", "Gaps in Research"]},
22
+ {"title": "Methodology", "content": ["Research Design", "Data Collection", "Data Analysis"]},
23
+ {"title": "Results", "content": ["Data Presentation", "Statistical Analysis", "Interpretation"]},
24
+ {"title": "Discussion and Conclusion", "content": ["Summary of Findings", "Implications", "Recommendations for Future Research"]}
25
+ ]
26
+
27
+ # Loop through each section and create a slide for it
28
+ for section in sections:
29
+ slide_layout = prs.slide_layouts[1] # 0 is for title slide, 1 for title and content
30
+ slide = prs.slides.add_slide(slide_layout)
31
+ title_placeholder = slide.shapes.title
32
+ body_placeholder = slide.placeholders[1]
33
+
34
+ # Set the title and content on the slide
35
+ title_placeholder.text = section["title"]
36
+ tf = body_placeholder.text_frame
37
+ for point in section["content"]:
38
+ p = tf.add_paragraph()
39
+ p.text = point
40
+
41
+ # Add a references slide
42
+ references_slide_layout = prs.slide_layouts[1] # Using title and content layout
43
+ references_slide = prs.slides.add_slide(references_slide_layout)
44
+ references_title = references_slide.shapes.title
45
+ references_body = references_slide.placeholders[1]
46
+ references_title.text = "References"
47
+ references_tf = references_body.text_frame
48
+ references = [
49
+ "Reference 1: Author Name. (Year). Title. Journal.",
50
+ "Reference 2: Author Name. (Year). Title. Journal.",
51
+ "Reference 3: Author Name. (Year). Title. Journal."
52
+ ] # Modify this list based on your actual references
53
+ for ref in references:
54
+ p = references_tf.add_paragraph()
55
+ p.text = ref
56
+
57
+ # Save the presentation
58
+ filename = 'detailed_research_presentation.pptx'
59
+ prs.save(filename)
60
+ return filename
61
+
62
+ # Streamlit UI
63
+ st.title('PowerPoint Presentation Generator')
64
+
65
+ if st.button('Generate Presentation'):
66
+ file_path = create_presentation()
67
+ with open(file_path, "rb") as file:
68
+ btn = st.download_button(
69
+ label="Download PowerPoint Presentation",
70
+ data=file,
71
+ file_name="research_presentation.pptx",
72
+ mime="application/vnd.openxmlformats-officedocument.presentationml.presentation"
73
+ )
74
+
75
+ st.write("Click the button above to generate and download a research presentation PowerPoint.")