-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for lines and connector shapes #28
Comments
Seconded. This would be an extremely helpful feature. |
I have python code that generates connector shapes. If it would help you with this library, I can send you a copy. |
Sure, want to fork and then send a pull request? I'll be happy to take a look :) |
Checking on this one as we need to be able to draw a polygon on a slide (Outlining areas of a picture) and I don't see a way to do this without it. Thanks! |
If a normal-ish polygon will do the trick, you could pick a suitable AutoShape (rectangle, circle, pentagon, etc.) and set its fill to no-fill and set its outline color and width to suit. That would certainly be a lot less work that forming it from individual lines. Note that with adjustment handles you can exercise quite a bit of control over shapes that have them. Lines/connectors are not on the immediate roadmap, although they are relatively high up in the backlog sequence/priority. |
Something like this will work from pptx import Presentation
from pptx.util import *
from lxml import objectify
from pptx.oxml.ns import nsdecls
title_only_slide_layout = prs.slide_layouts[5]
slide = prs.slides.add_slide(title_only_slide_layout)
shapes = slide.shapes
self._add_line_sp(shapes,2284189,1701577,0,3959671)
def _add_line_sp(self,shapes, x, y, cx, cy):
line_tmpl = """
<p:sp %s>
<p:nvSpPr>
<p:cNvPr id="%s" name="%s"/>
<p:cNvSpPr>
<a:spLocks noChangeShapeType="1"/>
</p:cNvSpPr>
<p:nvPr/>
</p:nvSpPr>
<p:spPr bwMode="auto">
<a:xfrm>
<a:off x="%s" y="%s"/>
<a:ext cx="%s" cy="%s"/>
</a:xfrm>
<a:prstGeom prst="line">
<a:avLst/>
</a:prstGeom>
<a:noFill/>
<a:ln w="25560" cap="sq">
<a:solidFill>
<a:srgbClr val="0000FF"/>
</a:solidFill>
<a:round/>
<a:headEnd type="triangle" w="med" len="med"/>
<a:tailEnd type="triangle" w="med" len="med"/>
</a:ln>
</p:spPr>
</p:sp>
""" % (nsdecls('p', 'a'), '%d', '%s', '%d', '%d', '%d', '%d')
id_ = shapes._next_shape_id
name = 'Line %d' % (id_-1)
#x = 2284189
#y = 1701577
#cx = 0
#cy = 3959671
line_xml = line_tmpl %(id_, name, x, y, cx, cy)
line_obj = objectify.fromstring(line_xml)
shapes._spTree.append(line_obj) |
@scanny @thomasysliu are you interested in working on this? I'd be interested in funding it. We have a requirement for loading a networkx json file into a .pptx slide showing nodes and edges. The nodes would be images/icons provided by references in the JSON. |
@johnrfrank Yes, we have a mechanism for sponsored features. If you contact me at the email on my profile page https://github.com/scanny if you like and we can set up a quick call. |
Added in release v0.6.1 on Oct 9, 2016. |
No description provided.
The text was updated successfully, but these errors were encountered: