Adding autoshapes
Add autoshapes using theadd_shape() method with a shape type from MSO_SHAPE:
Available shape types
TheMSO_SHAPE enumeration provides 182 shape types:
Understanding EMU (English Metric Units)
PowerPoint internally uses EMU for measurements. python-pptx provides conversion utilities:Position and dimensions
Control shape position and size:Fill formatting
Customize the interior appearance of shapes:- Solid color
- Theme color
- No fill (transparent)
Theme colors
Available theme color options fromMSO_THEME_COLOR:
ACCENT_1throughACCENT_6- Theme accent colorsBACKGROUND_1,BACKGROUND_2- Background colorsDARK_1,DARK_2- Dark theme colorsLIGHT_1,LIGHT_2- Light theme colorsHYPERLINK- Hyperlink colorFOLLOWED_HYPERLINK- Followed hyperlink color
Line formatting
Customize shape outlines:Shape adjustments
Many autoshapes have adjustment handles (yellow diamonds in PowerPoint) that modify their appearance:Understanding adjustment values
Adjustment values are normalized floats:- Nominal range: 0.0 to 1.0
- Value of 0.5: Typically represents 50% of shape width/height
- Negative values: Valid, may extend beyond shape boundaries
- Values > 1.0: Valid, may extend beyond shape boundaries
Complex shape adjustments
Shapes can have multiple adjustments (up to 8):Rotation
Rotate shapes by setting therotation property:
Adding text to shapes
All autoshapes can contain text via their text frame:Complete examples
Best practices
- Use
Inches(),Cm(), orPt()for measurements instead of raw EMU values - Use theme colors when possible for consistency across presentations
- Test adjustment values interactively in PowerPoint before coding
- Group related shapes using the grouping functionality
- Set explicit dimensions rather than relying on defaults
- Use descriptive variable names when working with multiple adjustments
- Consider shape rotation for dynamic layouts
To explore adjustment values, add a shape in PowerPoint, adjust it manually, then examine the XML using tools like
opc-diag to see the generated values.