python-pptx

How to delete unpopulated placeholder items using python-pptx

雨燕双飞 提交于 2020-01-14 07:46:10
问题 This is very simple, but I cannot find the actual method anywhere in the documentation or otherwise. I am using the python-pptx module and all I need to do is delete a single placeholder item, an empty text box, on some slides (without having to create a completely new layout just for these slides) - the closest thing to an answer is here: http://python-pptx.readthedocs.io/en/latest/user/placeholders-understanding.html under Unpopulated vs. populated but it still does not say how to actually

Adding dataframe and text in ppt using python-pptx in slide layout 3

爷,独闯天下 提交于 2020-01-10 06:01:27
问题 I have created ppt using the below code: prs = Presentation() class MySlide: def __init__(self, data): self.layout = prs.slide_layouts[data[2]] self.slide=prs.slides.add_slide(self.layout) self.title=self.slide.shapes.title self.title.text=data[0] self.subtitle=self.slide.placeholders[1] self.subtitle.text=data[1] slides = [ ["USA Weather", #data[0] "Subtitle(Bullet)", 3], ["Malaysia Weather", #data[0] "Content(Bullet)", 3], ["China Weather", #data[0] "This is a brown Fox", 3] ] for each

Adding dataframe and text in ppt using python-pptx in slide layout 3

你离开我真会死。 提交于 2020-01-10 06:01:11
问题 I have created ppt using the below code: prs = Presentation() class MySlide: def __init__(self, data): self.layout = prs.slide_layouts[data[2]] self.slide=prs.slides.add_slide(self.layout) self.title=self.slide.shapes.title self.title.text=data[0] self.subtitle=self.slide.placeholders[1] self.subtitle.text=data[1] slides = [ ["USA Weather", #data[0] "Subtitle(Bullet)", 3], ["Malaysia Weather", #data[0] "Content(Bullet)", 3], ["China Weather", #data[0] "This is a brown Fox", 3] ] for each

How does one define , extract and replace data from a Chart in an existing Powerpoint using Python

雨燕双飞 提交于 2020-01-07 05:34:28
问题 Currently I am using the following code to define and replace Placeholder (Text data) in existing Powerpoint presentations. current_dir = os.path.dirname(os.path.realpath(__file__)) prs = Presentation(current_dir + '/test2.pptx') slides = prs.slides title_slide_layout = prs.slide_layouts[0] slide = slides[0] for shape in slide.placeholders: print('%d %s' % (shape.placeholder_format.idx, shape.name)) title = slide.shapes.title subtitle1 = slide.shapes.placeholders[0] subtitle2 = slide.shapes

How do you set the font size of a Chart Title with Python PPTX?

≯℡__Kan透↙ 提交于 2020-01-04 09:07:59
问题 I add a chart with: doughnutchart_data.add_series('YTD COMPLETION TO PLAN', (PerformancePercent, NotPerformedPercent)) This gives me a chart title with the text, but how do I change the font size? This: ThisDoughnutChart.title.font.size = Pt(12) Gives me this error: AttributeError: 'Chart' object has no attribute 'title' 回答1: It seems that creating a chart title text_frame over writes the title applied from the add_series attribute. So I tried adding a new title. This worked for me:

How do you set the font size of a Chart Title with Python PPTX?

会有一股神秘感。 提交于 2020-01-04 09:07:12
问题 I add a chart with: doughnutchart_data.add_series('YTD COMPLETION TO PLAN', (PerformancePercent, NotPerformedPercent)) This gives me a chart title with the text, but how do I change the font size? This: ThisDoughnutChart.title.font.size = Pt(12) Gives me this error: AttributeError: 'Chart' object has no attribute 'title' 回答1: It seems that creating a chart title text_frame over writes the title applied from the add_series attribute. So I tried adding a new title. This worked for me:

Using loops in python-pptx to create multiple slides and writing dataframe to slides

醉酒当歌 提交于 2019-12-31 02:48:04
问题 I have the below code for creating ppt out of dataframes: Below is a snippet of the code for 3 slides: title_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(title_slide_layout) slide2 = prs.slides.add_slide(title_slide_layout) slide3 = prs.slides.add_slide(title_slide_layout) title = slide.shapes.title title.text = "Summary Table" title2 = slide2.shapes.title title2.text = "New Table" title3 = slide3.shapes.title title3.text = "Old Table" Since i have to create multiple such

python pptx inconsistant text frame location

落爺英雄遲暮 提交于 2019-12-25 08:33:00
问题 I add text to a pptx slide, and wan't it to be aligned properly. i use the following code placing = (slide.width/2,0,slide.width/4,0) txBox = slide.shapes.add_textbox(placing[0], placing[1], placing[2], placing[3]) tf = txBox.text_frame tf.margin_left = 0 tf.text = text it works, but the location is not consistent, the text starts at a different "left" location when the text grown longer or shorter. what am i missing here? is it possible that the text frame grows larger when the text is

How can I get the dimensions of a picture placeholder to re-size an image when creating a presentation and inserting a picture using python-pptx?

冷暖自知 提交于 2019-12-24 20:32:53
问题 I'm trying to insert a picture that is re-sized to fit the dimensions of the picture placeholder from a template using python-pptx. I don't believe the API has direct access to this from what I can find out in the docs. Is there any suggestion of how I might be able to do this, using the library or other? I have a running code that will insert a series of images into a set of template slides to automatically create a report using Powerpoint. Here is the function that is doing the majority of

python-pptx: How canI reposition the picture placeholder?

 ̄綄美尐妖づ 提交于 2019-12-24 11:29:49
问题 I'm relatively new to the python-pptx package but I'm finding it very useful. I've added a slide with the "title and picture and caption" layout. SLD_LAYOUT_TITLE_AND_PICTURE_AND_CAPTION = 8 prs = Presentation(output_pptx_fp) slide_layout = prs.slide_layouts[SLD_LAYOUT_TITLE_AND_PICTURE_AND_CAPTION] slide = prs.slides.add_slide(slide_layout) shapes = slide.shapes placeholder_pict = slide.placeholders[1] # idx key, not position placeholder_pict.insert_picture(img_path) I'm trying to figure out