Using lists in PowerPoint allows you to present information in a structured and visually appealing way. They help break down complex ideas into digestible points, making it easier for your audience to understand and retain key concepts. Whether you're creating a slide deck for a business presentation, educational workshop, or conference talk, incorporating lists can enhance the visual appeal and effectiveness of your content. In this article, we will demonstrate how to create numbered lists and bulleted lists in PowerPoint presentations in Python using Spire.Presentation for Python.
- Create a Numbered List in PowerPoint in Python
- Create a Bulleted List with Symbol Bullets in PowerPoint in Python
- Create a Bulleted List with Image Bullets in PowerPoint in Python
Install Spire.Presentation for Python
This scenario requires Spire.Presentation for Python and plum-dispatch v1.7.4. They can be easily installed in your Windows through the following pip command.
pip install Spire.Presentation
If you are unsure how to install, please refer to this tutorial: How to Install Spire.Presentation for Python on Windows
Create a Numbered List in PowerPoint in Python
Spire.Presentation supports adding numerals or bullet points in front of paragraphs to create a numbered or bulleted list. To specify the bullet type, you can use the ParagraphProperties.BulletType property. The following are the steps to create a numbered list in a PowerPoint slide using Spire.Presentation for Python.
- Create a Presentation object.
- Get the first slide using Presentation.Slides[0] property.
- Append a shape to the slide using ISlide.Shapes.AppendShape() method and set the shape style.
- Specify the items of the numbered list inside a list.
- Create paragraphs based on the list items, and set the bullet type of these paragraphs to Numbered using ParagraphProperties.BulletType property.
- Set the numbered bullet style of these paragraphs using ParagraphProperties.BulletStyle property.
- Add these paragraphs to the shape using IAutoShape.TextFrame.Paragraphs.Append() method.
- Save the document to a PowerPoint file using Presentation.SaveToFile() method.
- Python
from spire.presentation.common import * from spire.presentation import * # Create an object of the Presentation class presentation = Presentation() # Get the first slide slide = presentation.Slides[0] # Add a shape to the slide and set the shape style shape = slide.Shapes.AppendShape(ShapeType.Rectangle, RectangleF(50.0, 50.0, 300.0, 200.0)) shape.Fill.FillType = FillFormatType.none shape.Line.FillType= FillFormatType.none # Add text to the default paragraph paragraph = shape.TextFrame.Paragraphs[0] paragraph.Text = "Required Web Development Skills:" paragraph.Alignment = TextAlignmentType.Left paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid paragraph.TextRanges[0].Fill.SolidColor.Color = Color.get_Black() # Specify the list items listItems = [ " Command-line Unix", " Vim", " HTML", " CSS", " Python", " JavaScript", " SQL" ] # Create a numbered list for item in listItems: textParagraph = TextParagraph() textParagraph.Text = item textParagraph.Alignment = TextAlignmentType.Left textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.get_Black() textParagraph.BulletType = TextBulletType.Numbered textParagraph.BulletStyle = NumberedBulletStyle.BulletArabicPeriod shape.TextFrame.Paragraphs.Append(textParagraph) # Save the result document presentation.SaveToFile("NumberedList.pptx", FileFormat.Pptx2013) presentation.Dispose()
Create a Bulleted List with Symbol Bullets in PowerPoint in Python
The process of creating a bulleted list with symbol bullets is very similar to that of creating a numbered list. The only difference is that you need to set the bullet type of the paragraphs to Symbol. The following are the steps.
- Create a Presentation object.
- Get the first slide using Presentation.Slides[0] property.
- Append a shape to the slide using ISlide.Shapes.AppendShape() method and set the shape style.
- Specify the items of the bulleted list inside a list.
- Create paragraphs based on the list items, and set the bullet type of these paragraphs to Symbol using ParagraphProperties.BulletType property.
- Add these paragraphs to the shape using IAutoShape.TextFrame.Paragraphs.Append() method.
- Save the document to a PowerPoint file using Presentation.SaveToFile() method.
- Python
from spire.presentation.common import * from spire.presentation import * # Create an object of the Presentation class presentation = Presentation() # Get the first slide slide = presentation.Slides[0] # Add a shape to the slide and set the shape style shape = slide.Shapes.AppendShape(ShapeType.Rectangle, RectangleF(50.0, 50.0, 350.0, 200.0)) shape.Fill.FillType = FillFormatType.none shape.Line.FillType = FillFormatType.none # Add text to the default paragraph paragraph = shape.TextFrame.Paragraphs[0] paragraph.Text = "Computer Science Subjects:" paragraph.Alignment = TextAlignmentType.Left paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid paragraph.TextRanges[0].Fill.SolidColor.Color = Color.get_Black() # Specify the list items listItems = [ " Data Structure", " Algorithm", " Computer Networks", " Operating System", " Theory of Computations", " C Programming", " Computer Organization and Architecture" ] # Create a symbol bulleted list for item in listItems: textParagraph = TextParagraph() textParagraph.Text = item textParagraph.Alignment = TextAlignmentType.Left textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.get_Black() textParagraph.BulletType = TextBulletType.Symbol shape.TextFrame.Paragraphs.Append(textParagraph) # Save the result document presentation.SaveToFile("SymbolBulletedList.pptx", FileFormat.Pptx2013) presentation.Dispose()
Create a Bulleted List with Image Bullets in PowerPoint in Python
To use an image as bullets, you need to set the bullet type of the paragraphs to Picture and then set the image as bullet points using the ParagraphProperties.BulletPicture.EmbedImage property. The following are the detailed steps.
- Create a Presentation object.
- Get the first slide using Presentation.Slides[0] property.
- Append a shape to the slide using ISlide.Shapes.AppendShape() method and set the shape style.
- Specify the items of the bulleted list inside a list.
- Create paragraphs based on the list items, and set the bullet type of these paragraphs to Picture using ParagraphProperties.BulletType property.
- Set an image as bullet points using ParagraphProperties.BulletPicture.EmbedImage property.
- Add these paragraphs to the shape using IAutoShape.TextFrame.Paragraphs.Append() method.
- Save the document to a PowerPoint file using Presentation.SaveToFile() method.
- Python
from spire.presentation.common import * from spire.presentation import * # Create an object of the Presentation class presentation = Presentation() # Get the first slide slide = presentation.Slides[0] # Add a shape to the slide and set the shape style shape = slide.Shapes.AppendShape(ShapeType.Rectangle, RectangleF(50.0, 50.0, 400.0, 180.0)) shape.Fill.FillType = FillFormatType.none shape.Line.FillType = FillFormatType.none # Add text to the default paragraph paragraph = shape.TextFrame.Paragraphs[0] paragraph.Text = "Project Task To-Do List:" paragraph.Alignment = TextAlignmentType.Left paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid paragraph.TextRanges[0].Fill.SolidColor.Color = Color.get_Black() # Specify the list items listItems = [ " Define projects and tasks you're working on", " Assign people to tasks", " Define the priority levels of your tasks", " Keep track of the progress status of your tasks", " Mark tasks as done when completed" ] # Create an image bulleted list for item in listItems: textParagraph = TextParagraph() textParagraph.Text = item textParagraph.Alignment = TextAlignmentType.Left textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.get_Black() textParagraph.BulletType = TextBulletType.Picture stream = Stream("icon.png") imageData = presentation.Images.AppendStream(stream) textParagraph.BulletPicture.EmbedImage = imageData shape.TextFrame.Paragraphs.Append(textParagraph) stream.Close() # Save the result document presentation.SaveToFile("ImageBulletedList.pptx", FileFormat.Pptx2013) presentation.Dispose()
Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.