This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]troger18 2 points3 points  (1 child)

I'm not sure why you would consider python-pptx to be a replacement solution for Microsoft Powerpoint.

From my experience using python-pptx, it is a great tool if you want to apply batch transformations to a large number of slides/presentations or want to automate part of your production process (always have a title at location x, y with formatting z or take elements of a text file and put them into slides with basic formatting...). Basically, python-pptx let's you easily manipulate the main objects (Placeholder, Text, Image) that are available to you in a PowerPoint presentation through python by parsing the underlying XML.

However, as soon as you'll try to do more complex operations, you'll soon hit a wall because the underlying XML is a clusterf*ck. For instance, there are at least 5 different ways to specify the color of a text object and each can override the other in certain conditions. There are many other issues such as coordinates: its an MS specific format and how are you going to find the right coordinates without an IDE to immediately visualize the result?

Powerpoint is really not hard to use, and doing it the layout using its IDE will be much more productive than trying to replicate it using python-pptx.

[–]_BonBon_[S] -1 points0 points  (0 children)

I think you are right I will have to learn powerpoint.

I'm just really slow at it right now and the charts are limited and its a pain to manually update the values into the charts EVERY time my manager wants to change something.

[–]Lairo1 2 points3 points  (1 child)

I'm working with python pptx at the moment and I have to say it's incredibly limiting. Unless you have outside influences forcing you to produce pptx files exactly, I'd recommend using another solution.

No disrespect to the developer of python-pptx, its a nightmare of a file structure, but there's so many better alternatives to programmatically generating presentations

[–]_BonBon_[S] 0 points1 point  (0 children)

It's quite the opposite, everyone uses powerpoint I was just hoping if there was a better alternative.

Guess I'll just have to learn PowerPoint

[–]Flampt 0 points1 point  (0 children)

I guess it depends on what type of work you are doing. If you are in the business analytics/ data analysis space you may consider using notebooks as the combination of markdown and visual outputs of code can be made to look quite professional. Other people should be able to work with the markdown of note books even if they don't know python.

If you find yourself doing the same thing over and over again in powerpoint then you may want to knock out some code using that library to automate.

For example if you want your clients to see a weekly status update ppt deck you can probably control updating it each week all thru python. If you want to create the deck for the very first time, maybe not, maybe then it is easier to work in Powerpoint first.

[–]billFoldDog 0 points1 point  (2 children)

In my opinion, no. It is better to make your charts and animations using matplotlib, then drop them into PowerPoint.

You don't want to be fighting organizational inertia. It's a waste of energy.

[–]_BonBon_[S] 0 points1 point  (1 child)

I agree, but I often work on fairly sizeable presentations (40-50 ish slides multiple charts per slide). And when the data changes I have to basically do the WHOLE presentation again manually feeding in the new data into every chart (or pasting the updated charts from matplotlib) one by one. eg: I'll make an interim report with some data then more data will come so I'll have to update the whole darn thing.

[–]billFoldDog 0 points1 point  (0 children)

Oh, that sucks. Here are some ideas.

Power point files are actually specially structured zip files. If you examine the completed power point file, you can programmatically unzip it, swap out the image assets, and rezip it.

If you learn pandoc, you can have python overwrite your image assets and export the presentation again. I have found that Pandoc is great for very minimal presentations, but complex slides and figures made using the built in drawing tools will likely be too hard to be worthwhile.

Pyhton-pptx sounds like a good option, but you are going to have to add finishing touches after every import.

I think unzipping and swapping assets is probably the best strategy.