Maryam Farhana
Maryam Farhana

Reputation: 21

How to insert dashed line in power point using python

i am currently stuck to insert dashed line in power point. there are module using MSO_LINE but not sure how to implement it.

Tq

Upvotes: 1

Views: 692

Answers (1)

Martin Packer
Martin Packer

Reputation: 763

From MSO_LINE_DASH_STYLE:

from pptx.enum.dml import MSO_LINE

shape.line.dash_style = MSO_LINE.DASH_DOT_DOT

(I didn't need a dashed line so I haven't done the above; I have solid lines if anything.)

Of course, you might not know how to draw a line. Try something like this:

def createLine(x0, y0, x1, y1, shapes):
    # Create line
    line = shapes.add_shape(MSO_SHAPE.LINE_INVERSE, x0, y0, x1 - x0, y1 - y0)

    # Set shape's outline attributes
    line.line.color.rgb = RGBColor(191, 191, 191)
    line.line.width = Pt(4.0)

Obviously you'll need to modify the above and perhaps combine the two fragments but hopefully this is enough to get you going.

Upvotes: 1

Related Questions