Skip to content
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

Closed
scanny opened this issue Jul 13, 2013 · 9 comments
Closed

Add support for lines and connector shapes #28

scanny opened this issue Jul 13, 2013 · 9 comments
Assignees
Milestone

Comments

@scanny
Copy link
Owner

scanny commented Jul 13, 2013

No description provided.

@ghost ghost assigned scanny Jul 13, 2013
@scanny scanny modified the milestones: Shortlist, v0.4.0 Apr 12, 2014
@oscartprom
Copy link

Seconded. This would be an extremely helpful feature.

@oscartprom
Copy link

I have python code that generates connector shapes. If it would help you with this library, I can send you a copy.

@scanny
Copy link
Owner Author

scanny commented May 27, 2014

Sure, want to fork and then send a pull request? I'll be happy to take a look :)

@scanny scanny added connector and removed feature labels Jun 15, 2014
@scanny scanny removed this from the Shortlist milestone Sep 22, 2014
@gridgazer
Copy link

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!

@scanny
Copy link
Owner Author

scanny commented Oct 6, 2014

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.

@scanny scanny modified the milestone: soon-ish Nov 16, 2014
@thomasysliu
Copy link

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)

@johnrfrank
Copy link

@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.

@scanny
Copy link
Owner Author

scanny commented Aug 13, 2016

@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.

@scanny
Copy link
Owner Author

scanny commented Oct 9, 2016

Added in release v0.6.1 on Oct 9, 2016.

@scanny scanny closed this as completed Oct 9, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants