MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / add_line_simple

Function add_line_simple

utils/pptx_utils.py:1592–1629  ·  view source on GitHub ↗

Add a simple horizontal or vertical line to the slide. Parameters: slide: The slide object. name: The name/label for the line shape. left_inch: The left (X) coordinate in inches for the starting point. top_inch: The top (Y) coordinate in inches for the starting

(slide, name, left_inch, top_inch, length_inch, thickness=2, color=(0, 0, 0), orientation="horizontal")

Source from the content-addressed store, hash-verified

1590 shape.height = Inches(height_inch)
1591
1592def add_line_simple(slide, name, left_inch, top_inch, length_inch, thickness=2, color=(0, 0, 0), orientation="horizontal"):
1593 """
1594 Add a simple horizontal or vertical line to the slide.
1595
1596 Parameters:
1597 slide: The slide object.
1598 name: The name/label for the line shape.
1599 left_inch: The left (X) coordinate in inches for the starting point.
1600 top_inch: The top (Y) coordinate in inches for the starting point.
1601 length_inch: The length of the line in inches.
1602 thickness: The thickness of the line in points (default is 2).
1603 color: An (R, G, B) tuple specifying the line color (default is black).
1604 orientation: "horizontal" or "vertical" (case-insensitive).
1605
1606 Returns:
1607 The created line shape object.
1608 """
1609 x1 = Inches(left_inch)
1610 y1 = Inches(top_inch)
1611
1612 if orientation.lower() == "horizontal":
1613 x2 = Inches(left_inch + length_inch)
1614 y2 = y1
1615 elif orientation.lower() == "vertical":
1616 x2 = x1
1617 y2 = Inches(top_inch + length_inch)
1618 else:
1619 raise ValueError("Orientation must be either 'horizontal' or 'vertical'")
1620
1621 # Create a straight connector (used as a line)
1622 line_shape = slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT, x1, y1, x2, y2)
1623 line_shape.name = name
1624
1625 # Set the line thickness and color
1626 line_shape.line.width = Pt(thickness)
1627 line_shape.line.color.rgb = RGBColor(*color)
1628
1629 return line_shape
1630
1631def set_paragraph_line_spacing(shape, line_spacing=1.0):
1632 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected