Update docs/tech_docs/python/economics_presentation_sample.md
This commit is contained in:
@@ -1,124 +1,122 @@
|
||||
## Sample Economic PowerPoint Presentation
|
||||
Certainly! Below is a template for a modified README.md that you can use for your project, with placeholders for embedding your Python code. This README is structured to provide comprehensive information about setting up and running your project, including the virtual environment setup and execution of the script.
|
||||
|
||||
```markdown
|
||||
# Economics 101 Presentation Generator
|
||||
|
||||
This project automates the creation of PowerPoint presentations for Economics 101, covering both macro and microeconomics topics. Utilizing the `python-pptx` library, this script generates a presentation with predefined slides tailored to advanced economic studies.
|
||||
|
||||
## Getting Started
|
||||
|
||||
These instructions will guide you through setting up your project environment and running the presentation generation script.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Python 3.6 or higher
|
||||
- pip and venv (usually come with Python installation)
|
||||
|
||||
### Setting Up a Virtual Environment
|
||||
|
||||
A virtual environment is crucial for managing project-specific dependencies. Follow these steps to set up your environment:
|
||||
|
||||
1. **Navigate to Your Project Directory:**
|
||||
|
||||
```bash
|
||||
cd path/to/your/project
|
||||
```
|
||||
|
||||
2. **Create the Virtual Environment:**
|
||||
|
||||
```bash
|
||||
python3 -m venv env
|
||||
```
|
||||
|
||||
3. **Activate the Environment:**
|
||||
|
||||
```bash
|
||||
source env/bin/activate
|
||||
```
|
||||
|
||||
### Installing Dependencies
|
||||
|
||||
With the virtual environment activated, install the required packages specified in `requirements.txt`.
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
The `requirements.txt` file should contain:
|
||||
```
|
||||
python-pptx==x.x.x
|
||||
# Add any additional dependencies here
|
||||
```
|
||||
|
||||
### Running the Script
|
||||
|
||||
Ensure your script is executable by updating its permissions (only required once):
|
||||
|
||||
```bash
|
||||
chmod u+x Economics_101_Presentation.py
|
||||
```
|
||||
|
||||
Run the script with:
|
||||
|
||||
```bash
|
||||
./Economics_101_Presentation.py
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```bash
|
||||
python3 Economics_101_Presentation.py
|
||||
```
|
||||
|
||||
### Presentation Structure
|
||||
|
||||
The script generates a PowerPoint presentation with the following slides:
|
||||
- Introduction to Economics
|
||||
- Macroeconomics Overview
|
||||
- Microeconomics Overview
|
||||
- Fundamental Concepts
|
||||
- Macroeconomic Indicators
|
||||
- Microeconomic Analysis
|
||||
- Monetary Policy
|
||||
- Fiscal Policy
|
||||
- International Trade
|
||||
- Conclusion
|
||||
|
||||
### Customizing the Presentation
|
||||
|
||||
The script allows for customization of slide content and layout. To modify the presentation structure, adjust the following code block in your script:
|
||||
|
||||
```python
|
||||
from pptx import Presentation
|
||||
from pptx.util import Inches, Pt
|
||||
from pptx.enum.shapes import MSO_SHAPE
|
||||
from pptx.enum.chart import XL_CHART_TYPE
|
||||
from pptx.chart.data import CategoryChartData
|
||||
from pptx.dml.color import RGBColor
|
||||
# Placeholder for the presentation structure code
|
||||
```
|
||||
|
||||
class PresentationCreator:
|
||||
"""
|
||||
A class to create PowerPoint presentations with predefined slide templates.
|
||||
|
||||
Attributes:
|
||||
prs (Presentation): A python-pptx Presentation object.
|
||||
title (str): The title of the presentation.
|
||||
"""
|
||||
def __init__(self, title="Presentation"):
|
||||
"""
|
||||
Initializes the PresentationCreator with a title for the presentation.
|
||||
|
||||
Args:
|
||||
title (str): The title of the presentation.
|
||||
"""
|
||||
self.prs = Presentation()
|
||||
self.title = title
|
||||
|
||||
def add_section_header_slide(self, title):
|
||||
"""
|
||||
Adds a section header slide with a given title.
|
||||
|
||||
Args:
|
||||
title (str): The title of the section.
|
||||
"""
|
||||
layout = self.prs.slide_layouts[1] # Use Title and Content layout
|
||||
slide = self.prs.slides.add_slide(layout)
|
||||
slide.shapes.title.text = title
|
||||
# Set a subtitle or a short description in the content placeholder if needed
|
||||
|
||||
def add_two_content_slide(self, title, left_content, right_content):
|
||||
"""
|
||||
Adds a slide with a title and two content sections side by side.
|
||||
|
||||
Args:
|
||||
title (str): The title of the slide.
|
||||
left_content (str): The content for the left section.
|
||||
right_content (str): The content for the right section.
|
||||
"""
|
||||
layout = self.prs.slide_layouts[1] # Reuse Title and Content layout
|
||||
slide = self.prs.slides.add_slide(layout)
|
||||
slide.shapes.title.text = title
|
||||
slide.placeholders[1].text = left_content # Placeholder for left content
|
||||
# Note: For a true side-by-side layout, consider adding a textbox or customizing the layout
|
||||
|
||||
def add_comparison_slide(self, title, content):
|
||||
"""
|
||||
Adds a slide designed for comparisons.
|
||||
|
||||
Note: This example simplifies to a single content area for demonstration.
|
||||
|
||||
Args:
|
||||
title (str): The title of the slide.
|
||||
content (str): The content for comparison.
|
||||
"""
|
||||
layout = self.prs.slide_layouts[1] # Simplified use of Title and Content layout
|
||||
slide = self.prs.slides.add_slide(layout)
|
||||
slide.shapes.title.text = title
|
||||
slide.placeholders[1].text = content # Placeholder for comparison content
|
||||
|
||||
def add_chart_slide(self, title, data):
|
||||
"""
|
||||
Adds a slide with a chart based on provided data.
|
||||
|
||||
Args:
|
||||
title (str): The title of the slide.
|
||||
data (dict): The data for the chart, including categories and series.
|
||||
"""
|
||||
slide_layout = self.prs.slide_layouts[5] # Use Title Only layout for more chart space
|
||||
slide = self.prs.slides.add_slide(slide_layout)
|
||||
slide.shapes.title.text = title
|
||||
|
||||
chart_data = CategoryChartData()
|
||||
chart_data.categories = data["categories"]
|
||||
for name, values in data["series"].items():
|
||||
chart_data.add_series(name, values)
|
||||
|
||||
x, y, cx, cy = Inches(2), Inches(1.5), Inches(6), Inches(4.5)
|
||||
chart = slide.shapes.add_chart(
|
||||
XL_CHART_TYPE.COLUMN_CLUSTERED, x, y, cx, cy, chart_data
|
||||
).chart
|
||||
# Chart style and colors can be customized further
|
||||
|
||||
def save_presentation(self, filename="presentation.pptx"):
|
||||
"""
|
||||
Saves the presentation to a file.
|
||||
|
||||
Args:
|
||||
filename (str): The filename or path to save the presentation.
|
||||
"""
|
||||
self.prs.save(filename)
|
||||
## Project Structure
|
||||
|
||||
# Example usage
|
||||
if __name__ == "__main__":
|
||||
creator = PresentationCreator("Economics 101 Presentation")
|
||||
|
||||
# Adding slides
|
||||
creator.add_section_header_slide("Introduction to Economic Theories")
|
||||
creator.add_two_content_slide("Supply and Demand", "Supply Side Analysis", "Demand Side Analysis")
|
||||
creator.add_comparison_slide("Economic Models", "Comparative Analysis")
|
||||
|
||||
# Chart data example for economic indicators
|
||||
chart_data_example = {
|
||||
"categories": ['2015', '2016', '2017', '2018', '2019'],
|
||||
"series": {
|
||||
"GDP Growth": (2.5, 2.9, 2.3, 3.1, 2.2),
|
||||
"Inflation Rate": (1.5, 1.8, 2.1, 1.9, 1.6),
|
||||
}
|
||||
}
|
||||
creator.add_chart_slide("Economic Indicators Over Time", chart_data_example)
|
||||
|
||||
# Saving the presentation
|
||||
creator.save_presentation("./Economics_101_Presentation.pptx")
|
||||
```
|
||||
This project follows a standard directory structure for clarity and organization:
|
||||
|
||||
- `src/`: Source code files
|
||||
- `docs/`: Documentation files
|
||||
- `tests/`: Test scripts and data
|
||||
- `data/`: Data files
|
||||
- `env/`: Virtual environment (not version-controlled)
|
||||
|
||||
## Deactivating the Virtual Environment
|
||||
|
||||
To exit the virtual environment when you're done working:
|
||||
|
||||
```bash
|
||||
deactivate
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions to the presentation generator are welcome! Please feel free to submit pull requests or create issues for bugs and feature requests.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the LICENSE file for details.
|
||||
```
|
||||
|
||||
Replace `path/to/your/project` with the actual path where your project is located, and adjust the `requirements.txt` content according to the actual dependencies and their versions used in your project. This README provides a comprehensive guide for users and contributors to set up, run, and understand the purpose and structure of your project.
|
||||
Reference in New Issue
Block a user