{"id":4188,"date":"2019-11-22T07:08:05","date_gmt":"2019-11-22T06:08:05","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=4188"},"modified":"2019-12-07T19:27:57","modified_gmt":"2019-12-07T18:27:57","slug":"python-to-create-quickly-powepoint-presentation","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/python-to-create-quickly-powepoint-presentation\/","title":{"rendered":"Python to create quickly Powepoint presentation"},"content":{"rendered":"<p>In the last post we&#8217;ve seen how to create a sort of <strong>Powepoint<\/strong> to make fast <strong>presentations<\/strong>, with no text. This time I will show you some code to make a fast presentation, with only text, but in Powepoint, using, of course, our beloved programming language (<strong>Python<\/strong>, in case you&#8217;re asking which is it). So&#8230; as usual, few lines to get the result and save a lot of time doing stuff. The more you save (time) the more you have to create content and other useful things in your life.<\/p>\n<pre class=\"lang:default decode:true \">from pptx import Presentation\r\nimport os\r\n\r\ndef create_slides(name=\"slides.pptx\", context=[\"siamo qui\"]):\r\n    \"Create slides out of the arg list like in the example\"\r\n    prs = Presentation()\r\n\r\n    # Iterate the list 'context' to create slides\r\n    for s in context:\r\n        # Choose a layout(1=normal page)\r\n        layout = prs.slide_layouts[1]\r\n        # add a slide with the above layout\r\n        slide = prs.slides\r\n        slide = slide.add_slide(layout)\r\n        # give it title and content\r\n        slide.shapes.title.text = s[0]\r\n        slide.placeholders[1].text = s[1]\r\n    prs.save(name)\r\n    os.startfile(name)\r\n\r\n\r\ncreate_slides(name=\"Slides.pptx\", context=[\r\n    [\"Capitolo 1\", \"Era una notte buia e tempestosa\"],\r\n    [\"Capitolo 2\", \"... e vissero felici e contenti\"]\r\n])\r\n<\/pre>\n<p>If you do not have it, install python-pptx with\u00a0<strong>pip install python-pptx<\/strong> from the cmd (on windows: win button + R and then type in the pop up window &#8216;cmd&#8217; without quotes.<\/p>\n<p><iframe loading=\"lazy\" title=\"Powerpoint slides with Python in minutes\" width=\"747\" height=\"420\" src=\"https:\/\/www.youtube.com\/embed\/Bt6KwbZF9p0?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>New version&#8230; v.2 of this script<\/h2>\n<p>You can find <a href=\"https:\/\/pythonprogramming.altervista.org\/python-to-powerpoint-2-0\/\">a new version of this script here<\/a>. So, be sure to check it, if you liked this one. There is a way to insert easily the slides in a multiline string, instead of a list (you do not have to deal with square parenthesis of apostrophes). Furthermore, you can add bullets! So go and <a href=\"https:\/\/pythonprogramming.altervista.org\/python-to-powerpoint-2-0\/\">check this script<\/a>.<\/p>\n<p>The new output:<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/python-to-powerpoint-2-0\/\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-4271 size-full\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/12\/powerpoint2.png\" alt=\"\" width=\"1073\" height=\"569\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/12\/powerpoint2.png 1073w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/12\/powerpoint2-320x170.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/12\/powerpoint2-960x509.png 960w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/12\/powerpoint2-768x407.png 768w\" sizes=\"auto, (max-width: 1073px) 100vw, 1073px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"How to make a presentation with Powerpoint quickly with python and python-pptx module\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/python-to-create-quickly-powepoint-presentation\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":4189,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[196],"tags":[405,632,4,633],"class_list":["post-4188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powerpoint","tag-powerpoint","tag-pptx","tag-python","tag-python-pptx"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":true,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=4188"}],"version-history":[{"count":4,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4188\/revisions"}],"predecessor-version":[{"id":4278,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4188\/revisions\/4278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/4189"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=4188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=4188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=4188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}