[英]Python-pptx drawing a vertical line
I am trying to draw a vertical line using python-pptx module but haven't been able.我正在尝试使用 python-pptx 模块绘制一条垂直线,但未能成功。
The below helps me draw a horizontal line but I am not sure how to get a vertical line in the slide下面帮助我画一条水平线,但我不知道如何在幻灯片中获得一条垂直线
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.shapes import MSO_SHAPE
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[1])
line1 = slide.shapes.add_shape(MSO_SHAPE.LINE_INVERSE, Inches(6), Inches(6), Inches(1), Inches(2))
prs.save('sample.pptx')
Use shapes.add_connector()
:使用
shapes.add_connector()
:
https://python-pptx.readthedocs.io/en/latest/api/shapes.html#pptx.shapes.shapetree.SlideShapes.add_connector https://python-pptx.readthedocs.io/en/latest/api/shapes.html#pptx.shapes.shapetree.SlideShapes.add_connector
Its signature is:它的签名是:
add_connector(connector_type, begin_x, begin_y, end_x, end_y)
and it's used like this:它是这样使用的:
from pptx.enum.shapes import MSO_CONNECTOR
from pptx.util import Cm
line = slide.shapes.add_connector(
MSO_CONNECTOR.STRAIGHT, Cm(2), Cm(2), Cm(10), Cm(10)
)
The first two length values specify the starting point and the remaining two specify the end point.前两个长度值指定起点,其余两个指定终点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.