Skip to content

Instantly share code, notes, and snippets.

@zgulde
Created July 20, 2022 02:31
Show Gist options
  • Save zgulde/1f0d74ec4576448f7c46f4028cd48001 to your computer and use it in GitHub Desktop.
Save zgulde/1f0d74ec4576448f7c46f4028cd48001 to your computer and use it in GitHub Desktop.

Random Utilities

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "8dc88fad",
"metadata": {},
"source": [
"```\n",
"pip install python-pptx\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "e2d6cf62",
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"from pptx import Presentation\n",
"from pptx.util import Inches\n",
"import io\n",
"import plotly.express as px"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "3b378336",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Title Slide',\n",
" 'Title and Content',\n",
" 'Section Header',\n",
" 'Two Content',\n",
" 'Comparison',\n",
" 'Title Only',\n",
" 'Blank',\n",
" 'Content with Caption',\n",
" 'Picture with Caption',\n",
" 'Title and Vertical Text',\n",
" 'Vertical Title and Text']"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[l.name for l in prs.slide_layouts]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f1606d8c",
"metadata": {},
"outputs": [],
"source": [
"prs = Presentation()\n",
"title_slide_layout = prs.slide_layouts[0]\n",
"slide = prs.slides.add_slide(title_slide_layout)\n",
"title = slide.shapes.title\n",
"subtitle = slide.placeholders[1]\n",
"\n",
"title.text = \"Hello, World!\"\n",
"subtitle.text = \"python-pptx was here!\""
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "857e1989",
"metadata": {},
"outputs": [],
"source": [
"bullet_slide_layout = prs.slide_layouts[1]\n",
"\n",
"slide = prs.slides.add_slide(bullet_slide_layout)\n",
"shapes = slide.shapes\n",
"\n",
"title_shape = shapes.title\n",
"body_shape = shapes.placeholders[1]\n",
"\n",
"title_shape.text = 'Adding a Bullet Slide'\n",
"\n",
"tf = body_shape.text_frame\n",
"tf.text = 'Find the bullet slide layout'\n",
"\n",
"p = tf.add_paragraph()\n",
"p.text = 'Use _TextFrame.text for first bullet'\n",
"p.level = 1\n",
"\n",
"p = tf.add_paragraph()\n",
"p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets'\n",
"p.level = 2"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "2ed41c26",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEICAYAAABRSj9aAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAvDklEQVR4nO3dd3xUZdbA8d9JCL2EEiBCQm+hJIQICEpxFQFRsFN0V9eVBeEF1BfFXld313dRkeKytnVBbICyCgI2EBQwCSR0CD20RAKhlyTn/WOG3RgTMoHJ3MnM+X4+82HmeZ6Ze+Z6PbnzzJ3ziKpijDEmcIU4HYAxxpjSZYneGGMCnCV6Y4wJcJbojTEmwFmiN8aYAGeJ3hhjApwlehPQROQZEZnhdBzGOMkSvQkqBRO/iNwqIqtF5KiIrBGRzvn67haRZfke9xKR5SKSLSJbRaR/gb70fI9jRWSxiGSJyB4RuTtfX2MRUREp537cSETmikimiGSIyKMFYlYRae6+Hy4i74nIPvdrvy4i4uXdZAKMJXoT7CKB+4CawPvAuxcYGw08AdR2/zvrfLIuRBQwxf36dwB/F5HLLhDDZ0Bj4Ergkfx/cAqoBawGYty3AcBtF4jZGEv0xj+JyE4RGS8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VSGf0RS1SXlS7z4hIB+BNYKCqHjrfrqr73P9mAHNxfUTzCVU9ev6jpLpWAgsTkTr4wf5yG0yBj9Slvb9EJAxXcpipqnMKGeLIMeZBXI4cY8XF5dQx5sn+cvP5MeZ+7SPAd7g+TeRXeseXt75s8MUNaEzRXy5ezy+/yFjlbi8HbAea8N8vMtr6MK5oXOvpdivQXgWolu/+D0BfH8ZVn//+YK4zsNu97xzdX+7+Grjm8av4an+53/t7wKsXGOPzY8zDuHx+jHkYl8+PMU/icuIYAyKAcPf9SsD3wABfHV9lZupG/HSRcg/iegqoDUwVEYAcdVWnq4fr4xu4/kO+r6pf+jCuW4GRIpIDnAIGq+uocnp/AdwELFLVE/meWqr7C+gO3AWsdc+jAjyGK4k6eYx5EpcTx5gncTlxjHkSF/j+GIsE/ikiobhmUj5S1c9FZES+uErt+LISCMYYE+ACaY7eGGNMISzRG2NMgLNEb4wxAc4SvTHGBDhL9MYYE+As0RtjTICzRG+MMQHu/wHKiOxZp9sMCQAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"plt.plot([1, 2, 3], [3, 1, 2])\n",
"plt.title('mpl!?!?!?!?!?')\n",
"f = io.BytesIO()\n",
"plt.savefig(f, format='png')\n",
"f.seek(0)\n",
"\n",
"img_path = f\n",
"\n",
"prs = Presentation()\n",
"blank_slide_layout = prs.slide_layouts[6]\n",
"slide = prs.slides.add_slide(blank_slide_layout)\n",
"\n",
"left = top = Inches(1)\n",
"pic = slide.shapes.add_picture(img_path, left, top)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "2cad1a4f",
"metadata": {},
"outputs": [],
"source": [
"df = px.data.tips().head()"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "f1a40ffa",
"metadata": {},
"outputs": [],
"source": [
"title_only_slide_layout = prs.slide_layouts[5]\n",
"slide = prs.slides.add_slide(title_only_slide_layout)\n",
"shapes = slide.shapes\n",
"\n",
"shapes.title.text = 'Adding a Table'\n",
"\n",
"rows = df.shape[0] + 1\n",
"cols = df.shape[1]\n",
"left = top = Inches(2.0)\n",
"width = Inches(6.0)\n",
"height = Inches(0.8)\n",
"\n",
"table = shapes.add_table(rows, cols, left, top, width, height).table\n",
"\n",
"# set column widths\n",
"# table.columns[0].width = Inches(2.0)\n",
"# table.columns[1].width = Inches(4.0)\n",
"\n",
"# write column headings\n",
"for i, column in enumerate(df):\n",
" table.cell(0, i).text = column\n",
" \n",
"for i, (_, row) in enumerate(df.iterrows(), start=1):\n",
" for j, x in enumerate(row.tolist()):\n",
" table.cell(i, j).text = str(x)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "643e8ebd",
"metadata": {},
"outputs": [],
"source": [
"prs.save('test.pptx')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b00d4699",
"metadata": {},
"outputs": [],
"source": [
"fig = plt.figure()\n",
"plt.plot([1, 2, 3], [3, 1, 2])\n",
"plt.title('mpl!?!?!?!?!?')\n",
"f = io.BytesIO()\n",
"plt.savefig(f, format='png')\n",
"f.seek(0)"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "0a0d55f4",
"metadata": {},
"outputs": [],
"source": [
"from subprocess import check_output"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "27451e7c",
"metadata": {},
"outputs": [],
"source": [
"f = io.BytesIO()\n",
"diagram = '''\n",
"graph g {\n",
" dpi=255\n",
" a -- b\n",
" b -- c\n",
" a -- c\n",
"}\n",
"'''\n",
"svg = check_output('dot -Tpng'.split(), input=diagram.encode())\n",
"f.write(svg)\n",
"f.seek(0)\n",
"\n",
"prs = Presentation()\n",
"blank_slide_layout = prs.slide_layouts[6]\n",
"slide = prs.slides.add_slide(blank_slide_layout)\n",
"\n",
"left = top = Inches(.25)\n",
"pic = slide.shapes.add_picture(f, left, top)\n",
"prs.save('test.pptx')"
]
},
{
"cell_type": "code",
"execution_count": 61,
"id": "394e9b97",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['__class__',\n",
" '__delattr__',\n",
" '__dict__',\n",
" '__dir__',\n",
" '__doc__',\n",
" '__eq__',\n",
" '__format__',\n",
" '__ge__',\n",
" '__getattribute__',\n",
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
" '__ne__',\n",
" '__new__',\n",
" '__reduce__',\n",
" '__reduce_ex__',\n",
" '__repr__',\n",
" '__setattr__',\n",
" '__sizeof__',\n",
" '__str__',\n",
" '__subclasshook__',\n",
" '__weakref__',\n",
" '_element',\n",
" 'element',\n",
" 'idx',\n",
" 'type']"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"slide = prs.slides.add_slide(prs.slide_layouts[1])\n",
"dir(slide.shapes[0].placeholder_format)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment