Git Product home page Git Product logo

Comments (9)

oscartprom avatar oscartprom commented on June 29, 2024

Seconded. This would be an extremely helpful feature.

from python-pptx.

oscartprom avatar oscartprom commented on June 29, 2024

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

from python-pptx.

scanny avatar scanny commented on June 29, 2024

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

from python-pptx.

gridgazer avatar gridgazer commented on June 29, 2024

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!

from python-pptx.

scanny avatar scanny commented on June 29, 2024

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.

from python-pptx.

thomasysliu avatar thomasysliu commented on June 29, 2024

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)

from python-pptx.

johnrfrank avatar johnrfrank commented on June 29, 2024

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

from python-pptx.

scanny avatar scanny commented on June 29, 2024

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

from python-pptx.

scanny avatar scanny commented on June 29, 2024

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

from python-pptx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.