Harbor format: 14 coding_additions tasks (part 7)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +27 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/about_relationships.rst +206 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/applescript.rst +46 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/index.rst +17 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/odds_and_ends.rst +106 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/python_packaging.rst +142 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/technical_topics.rst +22 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/web_resources.rst +89 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/runtests.rst +56 -0
- tasks/tasksmith-74f059424102/tests/source/docs/dev/xmlchemy.rst +184 -0
- tasks/tasksmith-74f059424102/tests/source/docs/index.rst +118 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/autoshapes.rst +247 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/charts.rst +276 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/concepts.rst +92 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/install.rst +25 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/intro.rst +25 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/notes.rst +130 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/placeholders-understanding.rst +128 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/placeholders-using.rst +243 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/presentations.rst +99 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/quickstart.rst +267 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/slides.rst +104 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/table.rst +311 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/text.rst +179 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/understanding-shapes.rst +89 -0
- tasks/tasksmith-74f059424102/tests/source/docs/user/use-cases.rst +22 -0
- tasks/tasksmith-74f059424102/tests/source/features/act-action.feature +88 -0
- tasks/tasksmith-74f059424102/tests/source/features/act-hyperlink.feature +53 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-axis-props.feature +187 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-axistitle-props.feature +44 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-category-access.feature +72 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-category-props.feature +24 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-chart.feature +108 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-charttitle-props.feature +44 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-data-props.feature +107 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-datalabels.feature +208 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-gridlines-props.feature +11 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-legend-access.feature +31 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-legend-props.feature +82 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-marker-props.feature +59 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-plot-props.feature +121 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-point-access.feature +37 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-point-props.feature +21 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-replace-data.feature +40 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-series.feature +144 -0
- tasks/tasksmith-74f059424102/tests/source/features/cht-ticklabels-props.feature +26 -0
- tasks/tasksmith-74f059424102/tests/source/features/dml-color.feature +22 -0
- tasks/tasksmith-74f059424102/tests/source/features/dml-effect.feature +29 -0
- tasks/tasksmith-74f059424102/tests/source/features/dml-fill.feature +106 -0
- tasks/tasksmith-74f059424102/tests/source/features/dml-line.feature +62 -0
.gitattributes
CHANGED
|
@@ -91,3 +91,30 @@ tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-4/ISO-IEC-295
|
|
| 91 |
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/docx-icon.emf filter=lfs diff=lfs merge=lfs -text
|
| 92 |
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/xlsx-icon.emf filter=lfs diff=lfs merge=lfs -text
|
| 93 |
tasks/tasksmith-74f059424102/environment/source/tests/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/docx-icon.emf filter=lfs diff=lfs merge=lfs -text
|
| 92 |
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/xlsx-icon.emf filter=lfs diff=lfs merge=lfs -text
|
| 93 |
tasks/tasksmith-74f059424102/environment/source/tests/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
|
| 94 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/act-props.pptm filter=lfs diff=lfs merge=lfs -text
|
| 95 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
|
| 96 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-axis-props.pptx filter=lfs diff=lfs merge=lfs -text
|
| 97 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-category-access.pptx filter=lfs diff=lfs merge=lfs -text
|
| 98 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-chart-props.pptx filter=lfs diff=lfs merge=lfs -text
|
| 99 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-chart-type.pptx filter=lfs diff=lfs merge=lfs -text
|
| 100 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-datalabels.pptx filter=lfs diff=lfs merge=lfs -text
|
| 101 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-legend-props.pptx filter=lfs diff=lfs merge=lfs -text
|
| 102 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-legend.pptx filter=lfs diff=lfs merge=lfs -text
|
| 103 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-plot-props.pptx filter=lfs diff=lfs merge=lfs -text
|
| 104 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-point-access.pptx filter=lfs diff=lfs merge=lfs -text
|
| 105 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-point-props.pptx filter=lfs diff=lfs merge=lfs -text
|
| 106 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-replace-data.pptx filter=lfs diff=lfs merge=lfs -text
|
| 107 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-series.pptx filter=lfs diff=lfs merge=lfs -text
|
| 108 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/cht-ticklabels-props.pptx filter=lfs diff=lfs merge=lfs -text
|
| 109 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/dml-fill.pptx filter=lfs diff=lfs merge=lfs -text
|
| 110 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/ph-populated-placeholders.pptx filter=lfs diff=lfs merge=lfs -text
|
| 111 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/shp-access-ole-object.pptx filter=lfs diff=lfs merge=lfs -text
|
| 112 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/shp-movie-props.pptx filter=lfs diff=lfs merge=lfs -text
|
| 113 |
+
tasks/tasksmith-74f059424102/tests/source/features/steps/test_files/shp-shapes.pptx filter=lfs diff=lfs merge=lfs -text
|
| 114 |
+
tasks/tasksmith-74f059424102/tests/source/spec/ISO-IEC-29500-1/ISO-IEC-29500-1.pdf filter=lfs diff=lfs merge=lfs -text
|
| 115 |
+
tasks/tasksmith-74f059424102/tests/source/spec/ISO-IEC-29500-2/ISO-IEC-29500-2.pdf filter=lfs diff=lfs merge=lfs -text
|
| 116 |
+
tasks/tasksmith-74f059424102/tests/source/spec/ISO-IEC-29500-3/ISO-IEC-29500-3.pdf filter=lfs diff=lfs merge=lfs -text
|
| 117 |
+
tasks/tasksmith-74f059424102/tests/source/spec/ISO-IEC-29500-4/ISO-IEC-29500-4.pdf filter=lfs diff=lfs merge=lfs -text
|
| 118 |
+
tasks/tasksmith-74f059424102/tests/source/src/pptx/templates/docx-icon.emf filter=lfs diff=lfs merge=lfs -text
|
| 119 |
+
tasks/tasksmith-74f059424102/tests/source/src/pptx/templates/xlsx-icon.emf filter=lfs diff=lfs merge=lfs -text
|
| 120 |
+
tasks/tasksmith-74f059424102/tests/source/tests/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/about_relationships.rst
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
About Part Relationships
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
Understanding Part Relationships
|
| 6 |
+
================================
|
| 7 |
+
|
| 8 |
+
An Open XML package part can have one or more relationships to other parts in
|
| 9 |
+
the package. For example, a slide layout has a relationship to the slide
|
| 10 |
+
master it inherits properties from. And if the slide layout includes an image,
|
| 11 |
+
such as a company logo, it will also have a relationship to the image part
|
| 12 |
+
corresponding to that logo's image file.
|
| 13 |
+
|
| 14 |
+
Conceptually, a part relationship might be stated::
|
| 15 |
+
|
| 16 |
+
Part x is related to part y of type z.
|
| 17 |
+
|
| 18 |
+
While these relationships are reciprocal in a way of thinking (e.g. part y is
|
| 19 |
+
also related to part x), in Open XML they are generally defined in one
|
| 20 |
+
direction only. For example, a slide may have a relationship to an image it
|
| 21 |
+
contains, but an image never has a stated relationships to a slide. One
|
| 22 |
+
exception to this is slide masters and slide layouts. A slide layout has a
|
| 23 |
+
relationship to the slide master it inherits from at the same time the slide
|
| 24 |
+
master has a relationship to each of the slide layouts that inherit from it.
|
| 25 |
+
|
| 26 |
+
In the example above, part x can be referred to as the *source part* or
|
| 27 |
+
*from-part*, part y as the *target part* or *to-part*, and type z as the
|
| 28 |
+
*relationship type*. The relationship type essentially ends up being the part
|
| 29 |
+
type of the target part (e.g. image, slide master, etc.).
|
| 30 |
+
|
| 31 |
+
Inbound and outbound relationships
|
| 32 |
+
----------------------------------
|
| 33 |
+
|
| 34 |
+
Each relationship is *outbound* for its source part and *inbound* for its
|
| 35 |
+
target part. The *outbound* relationships of a part are those found in its
|
| 36 |
+
*part relationship item*, commonly referred to as its "rels file". Only
|
| 37 |
+
outbound relationships are recorded in the package. Inbound relationships are
|
| 38 |
+
purely abstract, although they can be inferred from outbound relationships if
|
| 39 |
+
an application had a need for them.
|
| 40 |
+
|
| 41 |
+
Not all parts can have outbound relationships. For example, image and
|
| 42 |
+
presentation properties parts never have outbound relationships. All parts,
|
| 43 |
+
however, participate in at least one inbound relationship. Any part with no
|
| 44 |
+
inbound relationships could be removed from the package without consequence,
|
| 45 |
+
and probably should be. For example, if upon saving it was noticed that a
|
| 46 |
+
particular image had no inbound relationships, that image would be better not
|
| 47 |
+
written to the package. *(Makes me wonder whether loading a package by walking
|
| 48 |
+
its relationship graph might be a good idea in some instances.)*
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
Direct and indirect relationship references
|
| 52 |
+
-------------------------------------------
|
| 53 |
+
|
| 54 |
+
Each relationship is recorded as a relationship element in the rels file
|
| 55 |
+
belonging to a specific part. (The package relationship item ``/_rels/.rels``
|
| 56 |
+
is the only exception, it belongs to the package, not to any part). Each
|
| 57 |
+
relationship entry specifies a part-local relationship id (rId) for the
|
| 58 |
+
relationship, the relationship type (essentially the part type of the target,
|
| 59 |
+
e.g. slide, image), and a path the target part file. The source part is not
|
| 60 |
+
explicitly stated in the relationship entry, it is implicitly the part
|
| 61 |
+
the .rels file belongs to.
|
| 62 |
+
|
| 63 |
+
These can be thought of as *external relationship references* in that the rels
|
| 64 |
+
file is a separate package item, external to the part itself. However, in
|
| 65 |
+
certain cases, a relationship may be referenced within the XML of the
|
| 66 |
+
from-part. These can be thought of as *internal relationship references*.
|
| 67 |
+
|
| 68 |
+
As an example of where an internal relationship reference is required,
|
| 69 |
+
consider a slide containing images of three different products. Each picture
|
| 70 |
+
has a corresponding <p:pic> element in the slide's shape tree, each of which
|
| 71 |
+
must specify the particular image file it displays, distinguishing it from the
|
| 72 |
+
other two image files related to the slide.
|
| 73 |
+
|
| 74 |
+
The picture elements specify which of the related images to display using the
|
| 75 |
+
part-local relationship id (rId) matching the required image, 'rId2' in the
|
| 76 |
+
example below::
|
| 77 |
+
|
| 78 |
+
<p:blipFill>
|
| 79 |
+
<a:blip r:embed="rId2">
|
| 80 |
+
...
|
| 81 |
+
</a:blip>
|
| 82 |
+
</p:blipFill>
|
| 83 |
+
|
| 84 |
+
Which is an indirect reference to ``image1.png`` specified as the target of
|
| 85 |
+
'rId2' in the slide's rels file::
|
| 86 |
+
|
| 87 |
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
| 88 |
+
<Relationships xmlns="http://.../relationships">
|
| 89 |
+
<Relationship Id="rId1" Type="http://.../slideLayout" Target=".../slideLayout2.xml"/>
|
| 90 |
+
<Relationship Id="rId2" Type="http://.../image" Target=".../image1.png"/>
|
| 91 |
+
</Relationships>
|
| 92 |
+
|
| 93 |
+
This indirection makes sense as a way to limit the coupling of presentation
|
| 94 |
+
parts to the mechanics of package composition. For example, when the XML for
|
| 95 |
+
the slide part in the example above is being composed, the slide can determine
|
| 96 |
+
the reference to the image it's displaying without reference outside its own
|
| 97 |
+
natural scope. In contrast, determining the eventual location and filename of
|
| 98 |
+
that image in any particular package that was saved would require the slide
|
| 99 |
+
code to have visibility into the packaging process, which would prevent
|
| 100 |
+
packaging being delegated to a separate, black-box module.
|
| 101 |
+
|
| 102 |
+
Implicit and explicit relationships
|
| 103 |
+
-----------------------------------
|
| 104 |
+
|
| 105 |
+
There is also a distinction between implicit and explicit relationships which
|
| 106 |
+
is described in the spec (ECMA-376-1) in section 9.2. I haven't encountered
|
| 107 |
+
those yet in the context of PresentationML (the spec uses an example of
|
| 108 |
+
footnotes from WordprocessingML), so I do not discuss them here.
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
Relationship Mechanics
|
| 112 |
+
======================
|
| 113 |
+
|
| 114 |
+
Relationship life-cycle
|
| 115 |
+
-----------------------
|
| 116 |
+
|
| 117 |
+
A representation of a relationship must operate effectively in two distinct
|
| 118 |
+
situations, in-package and in-memory. They must also support lifecycle
|
| 119 |
+
transitions from in-package to in-memory and from in-memory back to
|
| 120 |
+
in-package.
|
| 121 |
+
|
| 122 |
+
Abstract model
|
| 123 |
+
--------------
|
| 124 |
+
|
| 125 |
+
Each relationship has the following abstract attributes
|
| 126 |
+
|
| 127 |
+
.. attribute:: source
|
| 128 |
+
|
| 129 |
+
The "from-part" of the relationship.
|
| 130 |
+
|
| 131 |
+
.. attribute:: id
|
| 132 |
+
|
| 133 |
+
Source-local unique identifier for this relationship. Each source part's
|
| 134 |
+
relationship ids should be a sequence of consecutive integers starting from
|
| 135 |
+
1.
|
| 136 |
+
|
| 137 |
+
.. attribute:: target_type
|
| 138 |
+
|
| 139 |
+
The content type of the relationship's to-part.
|
| 140 |
+
|
| 141 |
+
.. attribute:: target
|
| 142 |
+
|
| 143 |
+
A direct reference to the relationship's to-part.
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
Maintaining relationships by dynamic parts (e.g. Slides)
|
| 148 |
+
========================================================
|
| 149 |
+
|
| 150 |
+
How will dynamic parts (like Slide) interact with its relationship list?
|
| 151 |
+
|
| 152 |
+
? Should it just add items to the relationship list when it creates new things?
|
| 153 |
+
|
| 154 |
+
? Does it need some sort of lookup capability in order to delete? Or just have a delete
|
| 155 |
+
relationship method on _Relationships or something like that.
|
| 156 |
+
|
| 157 |
+
Need to come up with a plausible set of use cases to think about a design.
|
| 158 |
+
Right now the only use case is loading a template into a presentation and
|
| 159 |
+
saving a presentation.
|
| 160 |
+
|
| 161 |
+
* Add an image to a slide.
|
| 162 |
+
|
| 163 |
+
* Change a slide's slide layout
|
| 164 |
+
|
| 165 |
+
* comment, notesSlide, tag, image, and slideLayout are the only outbound
|
| 166 |
+
relationship types for a slide, although I expect there are some other
|
| 167 |
+
DrawingML bits I haven't accounted for yet.
|
| 168 |
+
|
| 169 |
+
On reflection I'm thinking there's not too much urgency on noodling this out
|
| 170 |
+
too far, the present construction should work fine for now and be able to be
|
| 171 |
+
extended without disrupting other code too much.
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
SCRAP
|
| 175 |
+
=====
|
| 176 |
+
|
| 177 |
+
Rationale for Relationship to be an association class
|
| 178 |
+
-----------------------------------------------------
|
| 179 |
+
|
| 180 |
+
When loaded into memory, each relationship target must be a reference to an
|
| 181 |
+
active part object (or at least a part key that can be resolved to a
|
| 182 |
+
reference, but why do this lookup multiple times?). This is both because those
|
| 183 |
+
relationships can change and also because the package path, while it can be
|
| 184 |
+
calculated at runtime, is not guaranteed to be stable (e.g. a new slide can be
|
| 185 |
+
inserted between two existing ones) and is not finally resolved until the
|
| 186 |
+
presentation is saved.
|
| 187 |
+
|
| 188 |
+
General description of package relationships items
|
| 189 |
+
--------------------------------------------------
|
| 190 |
+
|
| 191 |
+
* Relationships items specify the relationships between parts of the package,
|
| 192 |
+
although they are not themselves a part.
|
| 193 |
+
|
| 194 |
+
* All relationship items are XML documents having a filename with the
|
| 195 |
+
extension '.rels' located in a directory named '_rels' located in the same
|
| 196 |
+
directory as the part.
|
| 197 |
+
|
| 198 |
+
* The package relationship item has the URI '/_rels/.rels'.
|
| 199 |
+
|
| 200 |
+
* Part relationship items have the same filename as the part whose
|
| 201 |
+
relationships they describe, with the '.rels' extension appended as a
|
| 202 |
+
suffix. For example, the relationship item for a part named
|
| 203 |
+
``/ppt/slides/slide1.xml`` would have the URI
|
| 204 |
+
``/ppt/slides/_rels/slide1.xml.rels``.
|
| 205 |
+
|
| 206 |
+
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/applescript.rst
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=====================
|
| 2 |
+
AppleScript Resources
|
| 3 |
+
=====================
|
| 4 |
+
|
| 5 |
+
In the fullness of time, it might make sense to incorporate some AppleScript
|
| 6 |
+
steps into the acceptance tests, to make sure that PowerPoint isn't barfing
|
| 7 |
+
after changes. I've collected some resources here that I discovered during
|
| 8 |
+
some preliminary resource discovery.
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
Resources
|
| 12 |
+
=========
|
| 13 |
+
|
| 14 |
+
* `Outlook archive message shortcut`_
|
| 15 |
+
* `AppleScript Essentials`_
|
| 16 |
+
* `AppleScript Essentials: Introduction to Scripting Microsoft PowerPoint`_
|
| 17 |
+
* `Applescript Microsoft 2011 PowerPoint`_
|
| 18 |
+
* `Converting VBA Macros to AppleScript in Microsoft Office`_
|
| 19 |
+
* `How can I use AppleScript to check if PowerPoint is playing a presentation?`_
|
| 20 |
+
* `AppleScript on Wikipedia`_
|
| 21 |
+
|
| 22 |
+
.. _`Outlook archive message shortcut`:
|
| 23 |
+
http://pastebin.com/m5imvA52
|
| 24 |
+
|
| 25 |
+
.. _`AppleScript Essentials`:
|
| 26 |
+
http://www.mactech.com/articles/mactech/Vol.23/23.03
|
| 27 |
+
/23.03AppleScriptPowerPoint/index.html
|
| 28 |
+
|
| 29 |
+
.. _`AppleScript Essentials: Introduction to Scripting Microsoft PowerPoint`:
|
| 30 |
+
http://www.mactech.com/articles/mactech/Vol.23/23.03
|
| 31 |
+
/23.03AppleScriptPowerPoint/index.html
|
| 32 |
+
|
| 33 |
+
.. _`Applescript Microsoft 2011 PowerPoint`:
|
| 34 |
+
http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macpowerpoint
|
| 35 |
+
/applescript-microsoft-2011-powerpoint-want-to
|
| 36 |
+
/2d71b92b-5ab4-4d75-a4fa-ed0b75b5e7b2?auth=1
|
| 37 |
+
|
| 38 |
+
.. _`Converting VBA Macros to AppleScript in Microsoft Office`:
|
| 39 |
+
http://www.mactech.com/vba-transition-guide/index-toc.html
|
| 40 |
+
|
| 41 |
+
.. _`How can I use AppleScript to check if PowerPoint is playing a presentation?`:
|
| 42 |
+
http://stackoverflow.com/questions/4695836/how-can-i-use-applescript-to
|
| 43 |
+
-check-if-powerpoint-is-playing-a-presentation
|
| 44 |
+
|
| 45 |
+
.. _`AppleScript on Wikipedia`:
|
| 46 |
+
http://en.wikipedia.org/wiki/AppleScript
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/index.rst
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=========
|
| 2 |
+
Resources
|
| 3 |
+
=========
|
| 4 |
+
|
| 5 |
+
... just collected bits and pieces here for now ...
|
| 6 |
+
|
| 7 |
+
.. toctree::
|
| 8 |
+
:maxdepth: 1
|
| 9 |
+
|
| 10 |
+
python_packaging
|
| 11 |
+
about_packaging
|
| 12 |
+
about_relationships
|
| 13 |
+
web_resources
|
| 14 |
+
technical_topics
|
| 15 |
+
applescript
|
| 16 |
+
odds_and_ends
|
| 17 |
+
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/odds_and_ends.rst
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=============
|
| 2 |
+
Odds and Ends
|
| 3 |
+
=============
|
| 4 |
+
|
| 5 |
+
Bits and pieces here without a more specific home
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
Class Hierarchy
|
| 9 |
+
===============
|
| 10 |
+
|
| 11 |
+
::
|
| 12 |
+
|
| 13 |
+
pptx
|
| 14 |
+
|
|
| 15 |
+
+--.packaging
|
| 16 |
+
|
|
| 17 |
+
+--_PartCollection
|
| 18 |
+
| |
|
| 19 |
+
| +--ImageParts
|
| 20 |
+
| +--SlideLayoutParts
|
| 21 |
+
| +--SlideMasterParts
|
| 22 |
+
| +--SlideParts
|
| 23 |
+
| +--ThemeParts
|
| 24 |
+
|
|
| 25 |
+
+--Part
|
| 26 |
+
|
|
| 27 |
+
+--CollectionPart
|
| 28 |
+
| |
|
| 29 |
+
| +--ImagePart
|
| 30 |
+
| +--SlideLayoutPart
|
| 31 |
+
| +--SlideMasterPart
|
| 32 |
+
| +--ThemePart
|
| 33 |
+
|
|
| 34 |
+
+--PresentationPart
|
| 35 |
+
+--PresPropsPart
|
| 36 |
+
+--SlidePart
|
| 37 |
+
+--TableStylesPart
|
| 38 |
+
+--ViewPropsPart
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
Also try something like this::
|
| 42 |
+
|
| 43 |
+
Exception hierarchy
|
| 44 |
+
-------------------
|
| 45 |
+
|
| 46 |
+
The class hierarchy for built-in exceptions is:
|
| 47 |
+
|
| 48 |
+
.. literalinclude:: ../../Lib/test/exception_hierarchy.txt
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
Feature adding process:
|
| 52 |
+
=======================
|
| 53 |
+
|
| 54 |
+
* Analysis
|
| 55 |
+
|
| 56 |
+
* Use case
|
| 57 |
+
* Aspects of the spec and PowerPoint conventions that bear on the feature
|
| 58 |
+
|
| 59 |
+
* Implementation strategy
|
| 60 |
+
|
| 61 |
+
* Test Cases
|
| 62 |
+
|
| 63 |
+
* Documentation
|
| 64 |
+
|
| 65 |
+
* Implementation
|
| 66 |
+
|
| 67 |
+
* Commit
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
Odds and Ends
|
| 71 |
+
=============
|
| 72 |
+
|
| 73 |
+
* DOC: Reserved Terms, e.g. package, part, item, element, etc. These have
|
| 74 |
+
special meaning because of the terminology of Open XML packages and
|
| 75 |
+
ElementTree XML conventions. Singleton, collection, perhaps tuple.
|
| 76 |
+
|
| 77 |
+
* DOC: Variable naming conventions. Variables containing XML elements are
|
| 78 |
+
named the same as the tag name of the element they hold. For example:
|
| 79 |
+
sldMaster = etree.parse('sldMaster1.xml')
|
| 80 |
+
|
| 81 |
+
* DOC: Suitable for server-side document generation, database publishing,
|
| 82 |
+
taking tedium out of building intricate slides that have a distinct pattern,
|
| 83 |
+
etc.
|
| 84 |
+
|
| 85 |
+
* DOC: Content Types mapping is discussed in ECMA-376-2 10.1.2 *Mapping
|
| 86 |
+
Content Types*
|
| 87 |
+
|
| 88 |
+
* DOC: Explicit vs. Implicit relationships are discussed in section 9.2 of
|
| 89 |
+
ECMA-376-1. Basically relationships to whole parts are explicit and
|
| 90 |
+
relationships to one of the elements within another part (like a footnote)
|
| 91 |
+
are implicit.
|
| 92 |
+
|
| 93 |
+
* DOC: [Open XML SDK How To's (How do I...)|
|
| 94 |
+
http://207.46.22.237/en-us/library/cc850828.aspx]
|
| 95 |
+
|
| 96 |
+
* DOC: [Good hints on where formatting comes from in
|
| 97 |
+
template|http://openxmldeveloper.org/discussions/formats/f/15/t/1301.aspx]
|
| 98 |
+
|
| 99 |
+
* Set work template slide layouts to standard type names for better layout
|
| 100 |
+
re-mapping on theme/template change
|
| 101 |
+
[http://msdn.microsoft.com/en-us/library/office/cc850846.aspx]
|
| 102 |
+
|
| 103 |
+
* spTree in cSld is a GroupShape (ShapeGroup?) perhaps Shape and ShapeGroup
|
| 104 |
+
are ... ? not sure who should inherit from the other. GroupShapes can
|
| 105 |
+
include other GroupShapes.
|
| 106 |
+
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/python_packaging.rst
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
================
|
| 2 |
+
Python packaging
|
| 3 |
+
================
|
| 4 |
+
|
| 5 |
+
Process Steps
|
| 6 |
+
=============
|
| 7 |
+
|
| 8 |
+
1. Develop **setup.py** and other `distribution-related files`_
|
| 9 |
+
#. Test distribution; should pass all `distribution tests`_
|
| 10 |
+
#. Register project with the Python Package Index (PyPI)
|
| 11 |
+
#. Upload distribution(s) to PyPI
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
.. _`distribution tests`:
|
| 15 |
+
|
| 16 |
+
Distribution tests
|
| 17 |
+
==================
|
| 18 |
+
|
| 19 |
+
* ``python setup.py sdist`` does not raise an exception
|
| 20 |
+
* all expected files are included in the distribution tarball
|
| 21 |
+
* ``python setup.py test`` works in install environment
|
| 22 |
+
* acceptance tests pass in install environment
|
| 23 |
+
* ``python setup.py install`` produces expected footprint in ``site-packages``
|
| 24 |
+
* easy_install works
|
| 25 |
+
* ``pip install python-pptx`` works
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
Test can install with all popular methods
|
| 29 |
+
-----------------------------------------
|
| 30 |
+
|
| 31 |
+
* manual
|
| 32 |
+
* easy_install
|
| 33 |
+
* pip
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
.. _`distribution-related files`:
|
| 37 |
+
|
| 38 |
+
Distribution-related files
|
| 39 |
+
==========================
|
| 40 |
+
|
| 41 |
+
* setup.py
|
| 42 |
+
* MANIFEST.in
|
| 43 |
+
* setup.cfg
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
----
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
Distribution user stories
|
| 50 |
+
=========================
|
| 51 |
+
|
| 52 |
+
... some notions about who uses these and for what ...
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
Roles
|
| 56 |
+
-----
|
| 57 |
+
|
| 58 |
+
* naive end-user
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
Use Cases
|
| 62 |
+
---------
|
| 63 |
+
|
| 64 |
+
Test build before distribution
|
| 65 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
"Just-works" installation
|
| 69 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 70 |
+
|
| 71 |
+
::
|
| 72 |
+
|
| 73 |
+
In order to enable a new capability in my computing environment
|
| 74 |
+
As a naive end-user
|
| 75 |
+
I would like installation to "just work" and not scare me with error
|
| 76 |
+
messages that don't indicate a real problem.
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
Install as a dependency
|
| 80 |
+
^^^^^^^^^^^^^^^^^^^^^^^
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
Verify installation
|
| 84 |
+
^^^^^^^^^^^^^^^^^^^
|
| 85 |
+
|
| 86 |
+
::
|
| 87 |
+
|
| 88 |
+
In order to verify a new installation
|
| 89 |
+
As a python developer
|
| 90 |
+
I want to be able to easily run the test suite without having to invest in
|
| 91 |
+
any additional discovery or configuration.
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
Resources
|
| 96 |
+
=========
|
| 97 |
+
|
| 98 |
+
* `The Hitchhiker’s Guide to Packaging`_
|
| 99 |
+
* `Writing a Package in Python`_ by Tarek Ziadé is an extract from his PACKT
|
| 100 |
+
book *Expert Python Programming* and while being somewhat dated, contains
|
| 101 |
+
some useful tidbits.
|
| 102 |
+
* Ian Bicking's blog post `Python's Makefile`_ discusses how to write
|
| 103 |
+
extensions to setup.py, for perhaps a command like ``coverage`` that would
|
| 104 |
+
automatically run ``nosetests --with-coverage``.
|
| 105 |
+
* `tox documentation`_
|
| 106 |
+
* `virtualenv documentation`_
|
| 107 |
+
* `How To Package Your Python Code`_
|
| 108 |
+
* `Python Packaging: Hate, hate, hate everywhere`_
|
| 109 |
+
* `Building and Distributing Packages with setuptools`_
|
| 110 |
+
* `A guide to Python packaging`_
|
| 111 |
+
* `Python Packaging by Tarek Ziade`_
|
| 112 |
+
|
| 113 |
+
.. _`The Hitchhiker’s Guide to Packaging`:
|
| 114 |
+
http://guide.python-distribute.org/index.html
|
| 115 |
+
|
| 116 |
+
.. _`Writing a Package in Python`:
|
| 117 |
+
http://zetcode.com/articles/packageinpython/
|
| 118 |
+
|
| 119 |
+
.. _`Python's Makefile`:
|
| 120 |
+
http://blog.ianbicking.org/pythons-makefile.html
|
| 121 |
+
|
| 122 |
+
.. _tox documentation:
|
| 123 |
+
http://tox.readthedocs.org/en/latest/
|
| 124 |
+
|
| 125 |
+
.. _virtualenv documentation:
|
| 126 |
+
http://www.virtualenv.org/en/latest/
|
| 127 |
+
|
| 128 |
+
.. _`Python Packaging: Hate, hate, hate everywhere`:
|
| 129 |
+
http://lucumr.pocoo.org/2012/6/22/hate-hate-hate-everywhere/
|
| 130 |
+
|
| 131 |
+
.. _How To Package Your Python Code:
|
| 132 |
+
http://www.scotttorborg.com/python-packaging/
|
| 133 |
+
|
| 134 |
+
.. _Building and Distributing Packages with setuptools:
|
| 135 |
+
http://peak.telecommunity.com/DevCenter/setuptools
|
| 136 |
+
|
| 137 |
+
.. _`A guide to Python packaging`:
|
| 138 |
+
http://www.ibm.com/developerworks/opensource/library/os-pythonpackaging/index.html
|
| 139 |
+
|
| 140 |
+
.. _`Python Packaging by Tarek Ziade`:
|
| 141 |
+
http://www.aosabook.org/en/packaging.html
|
| 142 |
+
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/technical_topics.rst
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
================
|
| 2 |
+
Technical Topics
|
| 3 |
+
================
|
| 4 |
+
|
| 5 |
+
Some technical topics that have become relevant to this project ...
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
Python Metaclasses
|
| 9 |
+
==================
|
| 10 |
+
|
| 11 |
+
* `Metaclass programming in Python`_
|
| 12 |
+
* `Python metaclasses by example`_
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
.. _`Metaclass programming in Python`:
|
| 16 |
+
http://www.ibm.com/developerworks/linux/library/l-pymeta/index.html
|
| 17 |
+
|
| 18 |
+
.. _`Python metaclasses by example`:
|
| 19 |
+
http://eli.thegreenplace.net/2011/08/14/python-metaclasses-by-example/
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/resources/web_resources.rst
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=============
|
| 2 |
+
Web Resources
|
| 3 |
+
=============
|
| 4 |
+
|
| 5 |
+
... just collected bits and pieces here for now ...
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
ECMA Spec
|
| 9 |
+
=========
|
| 10 |
+
...
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
Microsoft PowerPoint API documentation
|
| 14 |
+
======================================
|
| 15 |
+
|
| 16 |
+
* `PowerPoint 2010 Interop Namespace`_
|
| 17 |
+
|
| 18 |
+
* `PowerPoint 2013 Object Model Reference`_
|
| 19 |
+
|
| 20 |
+
* `PowerPoint 2010 Object Model Reference`_
|
| 21 |
+
|
| 22 |
+
* `Open XML Presentation Namespace on MSDN`_
|
| 23 |
+
|
| 24 |
+
* `Office 2013 Open XML Presentation Namespace`_
|
| 25 |
+
|
| 26 |
+
* `Open XML Content Types as an XML Document`_
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
.. _PowerPoint 2010 Interop Namespace:
|
| 30 |
+
http://msdn.microsoft.com/en-us/library/ff763170(v=office.14).aspx
|
| 31 |
+
|
| 32 |
+
.. _PowerPoint 2013 Object Model Reference:
|
| 33 |
+
http://msdn.microsoft.com/en-us/library/office/ff743835.aspx
|
| 34 |
+
|
| 35 |
+
.. _PowerPoint 2010 Object Model Reference:
|
| 36 |
+
http://msdn.microsoft.com/en-us/library/office/ff746846(v=office.14).aspx
|
| 37 |
+
|
| 38 |
+
.. _Open XML Presentation Namespace on MSDN:
|
| 39 |
+
http://msdn.microsoft.com/en-us/library/office/cc884925.aspx
|
| 40 |
+
|
| 41 |
+
.. _Office 2013 Open XML Presentation Namespace:
|
| 42 |
+
http://msdn.microsoft.com/en-us/library/cc884925.aspx
|
| 43 |
+
|
| 44 |
+
.. _Open XML Content Types as an XML Document:
|
| 45 |
+
http://blogs.msdn.com/b/ericwhite/archive/2007/12/11/openxml-content-
|
| 46 |
+
types-as-an-xml-document.aspx
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
Sphinx Resources
|
| 51 |
+
================
|
| 52 |
+
|
| 53 |
+
* Alternate source for `Sphinx documentation
|
| 54 |
+
<http://sphinx.readthedocs.org/en/latest/contents.html>`_
|
| 55 |
+
|
| 56 |
+
* `An example PyPi project
|
| 57 |
+
<http://packages.python.org/an_example_pypi_project/sphinx.html>`_
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
Documentation Guides
|
| 61 |
+
====================
|
| 62 |
+
|
| 63 |
+
* Nice GitHub Project Style Guide (esp. Commit Style Guide) `textmate /
|
| 64 |
+
restructuredtext.tmbundle
|
| 65 |
+
<https://github.com/textmate/restructuredtext.tmbundle>`_
|
| 66 |
+
|
| 67 |
+
* Python Documentation guide
|
| 68 |
+
`Documenting Python Guide <http://docs.python.org/devguide/documenting.html>`_
|
| 69 |
+
|
| 70 |
+
* `Google Python Style Guide <http://google-styleguide.googlecode.com/svn/trunk/pyguide.html>`_
|
| 71 |
+
|
| 72 |
+
* `Read The Docs (readthedocs.org) <https://docs.readthedocs.org/en/latest/index.html>`_
|
| 73 |
+
|
| 74 |
+
* `OpenComparison documetation on readthedocs.org <http://opencomparison.readthedocs.org/en/latest/contributing.html>`_
|
| 75 |
+
|
| 76 |
+
* `The Hitchhiker’s Guide to Packaging <http://guide.python-distribute.org/index.html>`_
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
Other Resources
|
| 80 |
+
===============
|
| 81 |
+
|
| 82 |
+
* `Python Magic Methods <http://www.rafekettler.com/magicmethods.html>`_
|
| 83 |
+
|
| 84 |
+
* `lxml.etree Tutorial <http://lxml.de/tutorial.html>`_
|
| 85 |
+
|
| 86 |
+
* `lxml API Reference <http://lxml.de/api/index.html>`_
|
| 87 |
+
|
| 88 |
+
* `The factory pattern in Python with __new__ <http://whilefalse.net/2009/10/21/factory-pattern-python-__new__/>`_
|
| 89 |
+
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/runtests.rst
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Running the test suite
|
| 3 |
+
======================
|
| 4 |
+
|
| 5 |
+
|pp| has a robust test suite, comprising over 600 tests at the time of writing,
|
| 6 |
+
both at the acceptance test and unit test levels. ``pytest`` is used for unit
|
| 7 |
+
tests, with help from the excellent ``mock`` library. ``behave`` is used for
|
| 8 |
+
acceptance tests.
|
| 9 |
+
|
| 10 |
+
You can run the tests from the source working directory using the following
|
| 11 |
+
commands::
|
| 12 |
+
|
| 13 |
+
$ py.test
|
| 14 |
+
============================ test session starts ============================
|
| 15 |
+
platform darwin -- Python 2.7.5 -- pytest-2.4.2
|
| 16 |
+
plugins: cov
|
| 17 |
+
collected 301 items
|
| 18 |
+
|
| 19 |
+
tests/test_oxml.py .........................................
|
| 20 |
+
tests/test_presentation.py ...................
|
| 21 |
+
tests/test_spec.py ........
|
| 22 |
+
tests/test_text.py ..........................
|
| 23 |
+
tests/test_util.py ...............
|
| 24 |
+
tests/opc/test_packaging.py .....................................................
|
| 25 |
+
tests/opc/test_rels.py ..............
|
| 26 |
+
tests/parts/test_coreprops.py .
|
| 27 |
+
tests/parts/test_image.py ...........
|
| 28 |
+
tests/parts/test_part.py ........
|
| 29 |
+
tests/parts/test_slides.py ..................
|
| 30 |
+
tests/shapes/test_autoshape.py ....................
|
| 31 |
+
tests/shapes/test_picture.py .
|
| 32 |
+
tests/shapes/test_placeholder.py .
|
| 33 |
+
tests/shapes/test_shape.py ...........
|
| 34 |
+
tests/shapes/test_shapetree.py ..............
|
| 35 |
+
tests/shapes/test_table.py ........................................
|
| 36 |
+
|
| 37 |
+
======================= 301 passed in 2.00 seconds ======================
|
| 38 |
+
|
| 39 |
+
$ behave
|
| 40 |
+
Feature: Add a text box to a slide
|
| 41 |
+
In order to accommodate a requirement for free-form text on a slide
|
| 42 |
+
As a presentation developer
|
| 43 |
+
I need the ability to place a text box on a slide
|
| 44 |
+
|
| 45 |
+
Scenario: Add a text box to a slide
|
| 46 |
+
Given I have a reference to a blank slide
|
| 47 |
+
When I add a text box to the slide's shape collection
|
| 48 |
+
And I save the presentation
|
| 49 |
+
Then the text box appears in the slide
|
| 50 |
+
|
| 51 |
+
# ... more output ...
|
| 52 |
+
|
| 53 |
+
13 features passed, 0 failed, 0 skipped
|
| 54 |
+
30 scenarios passed, 0 failed, 0 skipped
|
| 55 |
+
120 steps passed, 0 failed, 0 skipped, 0 undefined
|
| 56 |
+
Took 0m1.3s
|
tasks/tasksmith-74f059424102/tests/source/docs/dev/xmlchemy.rst
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Understanding ``xmlchemy``
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
``xmlchemy`` is an object-XML mapping layer somewhat reminiscent of
|
| 6 |
+
SQLAlchemy, hence the name. Mapping XML elements to objects is not nearly as
|
| 7 |
+
challenging as mapping to a relational database, so this layer is
|
| 8 |
+
substantially more modest. Nevertheless, it provides a powerful and very
|
| 9 |
+
useful abstraction layer around ``lxml``, particularly well-suited to
|
| 10 |
+
providing access to the broad schema of XML elements involved in the Open XML
|
| 11 |
+
standard.
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Additional topics to add ...
|
| 15 |
+
----------------------------
|
| 16 |
+
|
| 17 |
+
* understanding complex types in Open XML
|
| 18 |
+
* understanding attribute definitions Open XML
|
| 19 |
+
* understanding simple types in Open XML
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
Adding support for a new element type
|
| 23 |
+
-------------------------------------
|
| 24 |
+
|
| 25 |
+
* add a new custom element mapping to ``pptx.oxml.__init__``
|
| 26 |
+
* add a new custom element class in the appropriate ``pptx.oxml`` subpackage
|
| 27 |
+
module
|
| 28 |
+
* Add element definition members to the class
|
| 29 |
+
* Add attribute definition members to the class
|
| 30 |
+
* Add simple type definitions to ``pptx.oxml.simpletype``
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
Example
|
| 34 |
+
-------
|
| 35 |
+
|
| 36 |
+
::
|
| 37 |
+
|
| 38 |
+
from pptx.oxml.xmlchemy import BaseOxmlElement
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class CT_Foobar(BaseOxmlElement):
|
| 42 |
+
"""
|
| 43 |
+
Custom element class corresponding to ``CT_Foobar`` complex type
|
| 44 |
+
definition in pml.xsd or other Open XML schema.
|
| 45 |
+
"""
|
| 46 |
+
hlink = ZeroOrOne('a:hlink', successors=('a:rtl', 'a:extLst'))
|
| 47 |
+
eg_fillProperties = ZeroOrOneChoice(
|
| 48 |
+
(Choice('a:noFill'), Choice('a:solidFill'), Choice('a:gradFill'),
|
| 49 |
+
Choice('a:blipFill'), Choice('a:pattFill')),
|
| 50 |
+
successors=(
|
| 51 |
+
'a:effectLst', 'a:effectDag', 'a:highlight', 'a:uLnTx',
|
| 52 |
+
'a:uLn', 'a:uFillTx' 'a:extLst'
|
| 53 |
+
)
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
sz = OptionalAttribute(
|
| 57 |
+
'sz', ST_SimpleType, default=ST_SimpleType.OPTION
|
| 58 |
+
)
|
| 59 |
+
anchor = OptionalAttribute('i', XsdBoolean)
|
| 60 |
+
rId = RequiredAttribute('r:id', XsdString)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
Protocol
|
| 64 |
+
--------
|
| 65 |
+
|
| 66 |
+
::
|
| 67 |
+
|
| 68 |
+
>>> assert isinstance(foobar, CT_Foobar)
|
| 69 |
+
>>> foobar.hlink
|
| 70 |
+
None
|
| 71 |
+
>>> hlink = foobar._add_hlink()
|
| 72 |
+
>>> hlink
|
| 73 |
+
<pptx.oxml.xyz.CT_Hyperlink object at 0x10ab4b2d0>
|
| 74 |
+
>>> assert foobar.hlink is hlink
|
| 75 |
+
|
| 76 |
+
>>> foobar.eg_fillProperties
|
| 77 |
+
None
|
| 78 |
+
>>> foobar.solidFill
|
| 79 |
+
None
|
| 80 |
+
>>> solidFill = foobar.get_or_change_to_solidFill()
|
| 81 |
+
>>> solidFill
|
| 82 |
+
<pptx.oxml.xyz.CT_SolidFill object at 0x10ab4b2d0>
|
| 83 |
+
>>> assert foobar.eg_fillProperties is solidFill
|
| 84 |
+
>>> assert foobar.solidFill is solidFill
|
| 85 |
+
>>> foobar.remove_eg_fillProperties()
|
| 86 |
+
>>> foobar.eg_fillProperties
|
| 87 |
+
None
|
| 88 |
+
>>> foobar.solidFill
|
| 89 |
+
None
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
``OneAndOnlyOne`` element declaration
|
| 93 |
+
-------------------------------------
|
| 94 |
+
|
| 95 |
+
The ``OneAndOnlyOne`` callable generates the API for a required child
|
| 96 |
+
element::
|
| 97 |
+
|
| 98 |
+
childElement = OneAndOnlyOne('ns:localTagName')
|
| 99 |
+
|
| 100 |
+
Unlike the other element declarations, the call does not include
|
| 101 |
+
a ``successors`` argument. Since no API for inserting a new element is
|
| 102 |
+
generated, a successors list is not required.
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
Generated API
|
| 106 |
+
~~~~~~~~~~~~~
|
| 107 |
+
|
| 108 |
+
``childElement`` property (read-only)
|
| 109 |
+
Holds a reference to the child element object. Raises |InvalidXmlError|
|
| 110 |
+
on access if the required child element is not present.
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
Protocol
|
| 114 |
+
~~~~~~~~
|
| 115 |
+
|
| 116 |
+
::
|
| 117 |
+
|
| 118 |
+
>>> foobar.childElement
|
| 119 |
+
<pptx.oxml.xyz.CT_ChildElement object at 0x10ab4b2d0>
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
``RequiredAttribute`` attribute declaration
|
| 123 |
+
-------------------------------------------
|
| 124 |
+
|
| 125 |
+
::
|
| 126 |
+
|
| 127 |
+
reqAttr = RequiredAttribute('reqAtr', ST_SimpleType)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
Generated API
|
| 131 |
+
~~~~~~~~~~~~~
|
| 132 |
+
|
| 133 |
+
``childElement`` property (read/write)
|
| 134 |
+
Referencing the property returns the type-converted value of the
|
| 135 |
+
attribute as determined by the ``from_xml()`` method of the simple type
|
| 136 |
+
class appearing in the declaration (e.g. ST_SimpleType above).
|
| 137 |
+
Assignments to the property are validated by the ``validate()`` method of
|
| 138 |
+
the simple type class, potentially raising ``TypeError`` or
|
| 139 |
+
``ValueError``. Values are assigned in their natural Python type and are
|
| 140 |
+
encoded to the appropriate string value by the ``to_xml()`` method of the
|
| 141 |
+
simple type class.
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
``ZeroOrOne`` element declaration
|
| 145 |
+
---------------------------------
|
| 146 |
+
|
| 147 |
+
::
|
| 148 |
+
|
| 149 |
+
childElement = ZeroOrOne(
|
| 150 |
+
'ns:localTagName', successors=('ns:abc', 'ns:def')
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
Generated API
|
| 155 |
+
~~~~~~~~~~~~~
|
| 156 |
+
|
| 157 |
+
``childElement`` property (read-only)
|
| 158 |
+
Holds a reference to the child element object, or None if the element is
|
| 159 |
+
not present.
|
| 160 |
+
|
| 161 |
+
``get_or_add_childElement()`` method
|
| 162 |
+
Returns the child element object, newly added if not present.
|
| 163 |
+
|
| 164 |
+
``_add_childElement()`` empty element adder method
|
| 165 |
+
Returns a newly added empty child element having the declared tag name.
|
| 166 |
+
Adding is unconditional and assumes the element is not already present.
|
| 167 |
+
This method is called by the ``get_or_add_childElement()`` method as
|
| 168 |
+
needed and may be called by a hand-coded ``add_childElement()`` method
|
| 169 |
+
as needed. May be overridden to produce customized behavior.
|
| 170 |
+
|
| 171 |
+
``_new_childElement()`` empty element creator method
|
| 172 |
+
Returns a new "loose" child element of the declared tag name. Called by
|
| 173 |
+
``_add_childElement()`` to obtain a new child element, it may be
|
| 174 |
+
overridden to customize the element creation process.
|
| 175 |
+
|
| 176 |
+
``_insert_childElement(childElement)`` element inserter method
|
| 177 |
+
Returns the passed ``childElement`` after inserting it before any
|
| 178 |
+
successor elements, as listed in the ``successors`` argument of the
|
| 179 |
+
declaration. Called by ``_add_childElement()`` to insert the new element
|
| 180 |
+
it creates using ``_new_childElement()``.
|
| 181 |
+
|
| 182 |
+
``_remove_childElement()`` element remover method
|
| 183 |
+
Removes all instances of the child element. Does not raise an error if no
|
| 184 |
+
matching child elements are present.
|
tasks/tasksmith-74f059424102/tests/source/docs/index.rst
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
python-pptx
|
| 3 |
+
===========
|
| 4 |
+
|
| 5 |
+
Release v\ |version| (:ref:`Installation <install>`)
|
| 6 |
+
|
| 7 |
+
.. include:: ../README.rst
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
Philosophy
|
| 11 |
+
----------
|
| 12 |
+
|
| 13 |
+
|pp| aims to broadly support the PowerPoint format (PPTX, PowerPoint 2007 and later),
|
| 14 |
+
but its primary commitment is to be *industrial-grade*, that is, suitable for use in a
|
| 15 |
+
commercial setting. Maintaining this robustness requires a high engineering standard
|
| 16 |
+
which includes a comprehensive two-level (e2e + unit) testing regimen. This discipline
|
| 17 |
+
comes at a cost in development effort/time, but we consider reliability to be an
|
| 18 |
+
essential requirement.
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
Feature Support
|
| 22 |
+
---------------
|
| 23 |
+
|
| 24 |
+
|pp| has the following capabilities:
|
| 25 |
+
|
| 26 |
+
* Round-trip any Open XML presentation (.pptx file) including all its elements
|
| 27 |
+
* Add slides
|
| 28 |
+
* Populate text placeholders, for example to create a bullet slide
|
| 29 |
+
* Add image to slide at arbitrary position and size
|
| 30 |
+
* Add textbox to a slide; manipulate text font size and bold
|
| 31 |
+
* Add table to a slide
|
| 32 |
+
* Add auto shapes (e.g. polygons, flowchart shapes, etc.) to a slide
|
| 33 |
+
* Add and manipulate column, bar, line, and pie charts
|
| 34 |
+
* Access and change core document properties such as title and subject
|
| 35 |
+
* And many others ...
|
| 36 |
+
|
| 37 |
+
Even with all |pp| does, the PowerPoint document format is very rich and there are still
|
| 38 |
+
features |pp| does not support.
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
New features/releases
|
| 42 |
+
---------------------
|
| 43 |
+
|
| 44 |
+
New features are generally added via sponsorship. If there's a new feature you need for
|
| 45 |
+
your use case, feel free to reach out at the email address on the github.com/scanny
|
| 46 |
+
profile page. Many of the most used features such as charts were added this way.
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
User Guide
|
| 50 |
+
----------
|
| 51 |
+
|
| 52 |
+
.. toctree::
|
| 53 |
+
:maxdepth: 1
|
| 54 |
+
|
| 55 |
+
user/intro
|
| 56 |
+
user/install
|
| 57 |
+
user/quickstart
|
| 58 |
+
user/presentations
|
| 59 |
+
user/slides
|
| 60 |
+
user/understanding-shapes
|
| 61 |
+
user/autoshapes
|
| 62 |
+
user/placeholders-understanding
|
| 63 |
+
user/placeholders-using
|
| 64 |
+
user/text
|
| 65 |
+
user/charts
|
| 66 |
+
user/table
|
| 67 |
+
user/notes
|
| 68 |
+
user/use-cases
|
| 69 |
+
user/concepts
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
Community Guide
|
| 73 |
+
---------------
|
| 74 |
+
|
| 75 |
+
.. toctree::
|
| 76 |
+
:maxdepth: 1
|
| 77 |
+
|
| 78 |
+
community/faq
|
| 79 |
+
community/support
|
| 80 |
+
community/updates
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
.. _api:
|
| 84 |
+
|
| 85 |
+
API Documentation
|
| 86 |
+
-----------------
|
| 87 |
+
|
| 88 |
+
.. toctree::
|
| 89 |
+
:maxdepth: 2
|
| 90 |
+
|
| 91 |
+
api/presentation
|
| 92 |
+
api/slides
|
| 93 |
+
api/shapes
|
| 94 |
+
api/placeholders
|
| 95 |
+
api/table
|
| 96 |
+
api/chart-data
|
| 97 |
+
api/chart
|
| 98 |
+
api/text
|
| 99 |
+
api/action
|
| 100 |
+
api/dml
|
| 101 |
+
api/image
|
| 102 |
+
api/exc
|
| 103 |
+
api/util
|
| 104 |
+
api/enum/index
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
Contributor Guide
|
| 108 |
+
-----------------
|
| 109 |
+
|
| 110 |
+
.. toctree::
|
| 111 |
+
:maxdepth: 1
|
| 112 |
+
|
| 113 |
+
dev/runtests
|
| 114 |
+
dev/xmlchemy
|
| 115 |
+
dev/development_practices
|
| 116 |
+
dev/philosophy
|
| 117 |
+
dev/analysis/index
|
| 118 |
+
dev/resources/index
|
tasks/tasksmith-74f059424102/tests/source/docs/user/autoshapes.rst
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Working with AutoShapes
|
| 3 |
+
=======================
|
| 4 |
+
|
| 5 |
+
Auto shapes are regular shape shapes. Squares, circles, triangles, stars,
|
| 6 |
+
that sort of thing. There are 182 different auto shapes to choose from. 120
|
| 7 |
+
of these have adjustment "handles" you can use to change the shape, sometimes
|
| 8 |
+
dramatically.
|
| 9 |
+
|
| 10 |
+
Many shape types share a common set of properties. We'll introduce many of
|
| 11 |
+
them here because several of those shapes are just a specialized form of
|
| 12 |
+
AutoShape.
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
Adding an auto shape
|
| 16 |
+
--------------------
|
| 17 |
+
|
| 18 |
+
The following code adds a rounded rectangle shape, one inch square, and
|
| 19 |
+
positioned one inch from the top-left corner of the slide::
|
| 20 |
+
|
| 21 |
+
from pptx.enum.shapes import MSO_SHAPE
|
| 22 |
+
|
| 23 |
+
shapes = slide.shapes
|
| 24 |
+
left = top = width = height = Inches(1.0)
|
| 25 |
+
shape = shapes.add_shape(
|
| 26 |
+
MSO_SHAPE.ROUNDED_RECTANGLE, left, top, width, height
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
See the :ref:`MsoAutoShapeType` enumeration page for a list of all 182 auto
|
| 30 |
+
shape types.
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
.. _`EMU`:
|
| 34 |
+
|
| 35 |
+
Understanding English Metric Units
|
| 36 |
+
----------------------------------
|
| 37 |
+
|
| 38 |
+
In the prior example we set the position and dimension values to the
|
| 39 |
+
expression ``Inches(1.0)``. What's that about?
|
| 40 |
+
|
| 41 |
+
Internally, PowerPoint stores length values in *English Metric Units* (EMU).
|
| 42 |
+
This term might be worth a quick Googling, but the short story is EMU is an
|
| 43 |
+
integer unit of length, 914400 to the inch. Most lengths in Office documents
|
| 44 |
+
are stored in EMU. 914400 has the great virtue that it is evenly divisible by
|
| 45 |
+
a great many common factors, allowing exact conversion between inches and
|
| 46 |
+
centimeters, for example. Being an integer, it can be represented exactly
|
| 47 |
+
across serializations and across platforms.
|
| 48 |
+
|
| 49 |
+
As you might imagine, working directly in EMU is inconvenient. To make it
|
| 50 |
+
easier, python-pptx provides a collection of value types to allow easy
|
| 51 |
+
specification and conversion into convenient units::
|
| 52 |
+
|
| 53 |
+
>>> from pptx.util import Inches, Pt
|
| 54 |
+
>>> length = Inches(1)
|
| 55 |
+
>>> length
|
| 56 |
+
914400
|
| 57 |
+
>>> length.inches
|
| 58 |
+
1.0
|
| 59 |
+
>>> length.cm
|
| 60 |
+
2.54
|
| 61 |
+
>>> length.pt
|
| 62 |
+
72.0
|
| 63 |
+
>>> length = Pt(72)
|
| 64 |
+
>>> length
|
| 65 |
+
914400
|
| 66 |
+
|
| 67 |
+
More details are available in the :ref:`API documentation for pptx.util
|
| 68 |
+
<util>`
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
Shape position and dimensions
|
| 72 |
+
-----------------------------
|
| 73 |
+
|
| 74 |
+
All shapes have a position on their slide and have a size. In general,
|
| 75 |
+
position and size are specified when the shape is created. Position and size
|
| 76 |
+
can also be read from existing shapes and changed::
|
| 77 |
+
|
| 78 |
+
>>> from pptx.enum.shapes import MSO_SHAPE
|
| 79 |
+
>>> left = top = width = height = Inches(1.0)
|
| 80 |
+
>>> shape = shapes.add_shape(
|
| 81 |
+
>>> MSO_SHAPE.ROUNDED_RECTANGLE, left, top, width, height
|
| 82 |
+
>>> )
|
| 83 |
+
>>> shape.left, shape.top, shape.width, shape.height
|
| 84 |
+
(914400, 914400, 914400, 914400)
|
| 85 |
+
>>> shape.left.inches
|
| 86 |
+
1.0
|
| 87 |
+
>>> shape.left = Inches(2.0)
|
| 88 |
+
>>> shape.left.inches
|
| 89 |
+
2.0
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
Fill
|
| 93 |
+
----
|
| 94 |
+
|
| 95 |
+
AutoShapes have an outline around their outside edge. What appears within
|
| 96 |
+
that outline is called the shape's *fill*.
|
| 97 |
+
|
| 98 |
+
The most common type of fill is a solid color. A shape may also be filled
|
| 99 |
+
with a gradient, a picture, a pattern (like cross-hatching for example), or
|
| 100 |
+
may have no fill (transparent).
|
| 101 |
+
|
| 102 |
+
When a color is used, it may be specified as a specific RGB value or a color
|
| 103 |
+
from the theme palette.
|
| 104 |
+
|
| 105 |
+
Because there are so many options, the API for fill is a bit complex. This
|
| 106 |
+
code sets the fill of a shape to red::
|
| 107 |
+
|
| 108 |
+
>>> fill = shape.fill
|
| 109 |
+
>>> fill.solid()
|
| 110 |
+
>>> fill.fore_color.rgb = RGBColor(255, 0, 0)
|
| 111 |
+
|
| 112 |
+
This sets it to the theme color that appears as 'Accent 1 - 25% Darker' in
|
| 113 |
+
the toolbar palette::
|
| 114 |
+
|
| 115 |
+
>>> from pptx.enum.dml import MSO_THEME_COLOR
|
| 116 |
+
>>> fill = shape.fill
|
| 117 |
+
>>> fill.solid()
|
| 118 |
+
>>> fill.fore_color.theme_color = MSO_THEME_COLOR.ACCENT_1
|
| 119 |
+
>>> fill.fore_color.brightness = -0.25
|
| 120 |
+
|
| 121 |
+
This sets the shape fill to transparent, or 'No Fill' as it's called in the
|
| 122 |
+
PowerPoint UI::
|
| 123 |
+
|
| 124 |
+
>>> shape.fill.background()
|
| 125 |
+
|
| 126 |
+
As you can see, the first step is to specify the desired fill type by calling
|
| 127 |
+
the corresponding method on fill. Doing so actually changes the properties
|
| 128 |
+
available on the fill object. For example, referencing ``.fore_color`` on a
|
| 129 |
+
fill object after calling its ``.background()`` method will raise an
|
| 130 |
+
exception::
|
| 131 |
+
|
| 132 |
+
>>> fill = shape.fill
|
| 133 |
+
>>> fill.solid()
|
| 134 |
+
>>> fill.fore_color
|
| 135 |
+
<pptx.dml.color.ColorFormat object at 0x10ce20910>
|
| 136 |
+
>>> fill.background()
|
| 137 |
+
>>> fill.fore_color
|
| 138 |
+
Traceback (most recent call last):
|
| 139 |
+
...
|
| 140 |
+
TypeError: a transparent (background) fill has no foreground color
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
Line
|
| 144 |
+
----
|
| 145 |
+
|
| 146 |
+
The outline of an AutoShape can also be formatted, including setting its
|
| 147 |
+
color, width, dash (solid, dashed, dotted, etc.), line style (single, double,
|
| 148 |
+
thick-thin, etc.), end cap, join type, and others. At the time of writing,
|
| 149 |
+
color and width can be set using python-pptx::
|
| 150 |
+
|
| 151 |
+
>>> line = shape.line
|
| 152 |
+
>>> line.color.rgb = RGBColor(255, 0, 0)
|
| 153 |
+
>>> line.color.brightness = 0.5 # 50% lighter
|
| 154 |
+
>>> line.width = Pt(2.5)
|
| 155 |
+
|
| 156 |
+
Theme colors can be used on lines too::
|
| 157 |
+
|
| 158 |
+
>>> line.color.theme_color = MSO_THEME_COLOR.ACCENT_6
|
| 159 |
+
|
| 160 |
+
``Shape.line`` has the attribute ``.color``. This is essentially a shortcut
|
| 161 |
+
for::
|
| 162 |
+
|
| 163 |
+
>>> line.fill.solid()
|
| 164 |
+
>>> line.fill.fore_color
|
| 165 |
+
|
| 166 |
+
This makes sense for line formatting because a shape outline is most
|
| 167 |
+
frequently set to a solid color. Accessing the fill directly is required, for
|
| 168 |
+
example, to set the line to transparent::
|
| 169 |
+
|
| 170 |
+
>>> line.fill.background()
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
Line width
|
| 174 |
+
~~~~~~~~~~
|
| 175 |
+
|
| 176 |
+
The shape outline also has a read/write width property::
|
| 177 |
+
|
| 178 |
+
>>> line.width
|
| 179 |
+
9525
|
| 180 |
+
>>> line.width.pt
|
| 181 |
+
0.75
|
| 182 |
+
>>> line.width = Pt(2.0)
|
| 183 |
+
>>> line.width.pt
|
| 184 |
+
2.0
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
Adjusting an autoshape
|
| 188 |
+
----------------------
|
| 189 |
+
|
| 190 |
+
Many auto shapes have adjustments. In PowerPoint, these show up as little
|
| 191 |
+
yellow diamonds you can drag to change the look of the shape. They're a little
|
| 192 |
+
fiddly to work with via a program, but if you have the patience to get them
|
| 193 |
+
right, you can achieve some remarkable effects with great precision.
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
Shape Adjustment Concepts
|
| 197 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 198 |
+
|
| 199 |
+
There are a few concepts it's worthwhile to grasp before trying to do serious
|
| 200 |
+
work with adjustments.
|
| 201 |
+
|
| 202 |
+
First, adjustments are particular to a specific auto shape type. Each auto
|
| 203 |
+
shape has between zero and eight adjustments. What each of them does is
|
| 204 |
+
arbitrary and depends on the shape design.
|
| 205 |
+
|
| 206 |
+
Conceptually, adjustments are guides, in many ways like the light blue ones you
|
| 207 |
+
can align to in the PowerPoint UI and other drawing apps. These don't show, but
|
| 208 |
+
they operate in a similar way, each defining an x or y value that part of the
|
| 209 |
+
shape will align to, changing the proportions of the shape.
|
| 210 |
+
|
| 211 |
+
Adjustment values are large integers, each based on a nominal value of 100,000.
|
| 212 |
+
The effective value of an adjustment is proportional to the width or height of
|
| 213 |
+
the shape. So a value of 50,000 for an x-coordinate adjustment corresponds to
|
| 214 |
+
half the width of the shape; a value of 75,000 for a y-coordinate adjustment
|
| 215 |
+
corresponds to 3/4 of the shape height.
|
| 216 |
+
|
| 217 |
+
Adjustment values can be negative, generally indicating the coordinate is to
|
| 218 |
+
the left or above the top left corner (origin) of the shape. Values can also be
|
| 219 |
+
subject to limits, meaning their effective value cannot be outside a prescribed
|
| 220 |
+
range. In practice this corresponds to a point not being able to extend beyond
|
| 221 |
+
the left side of the shape, for example.
|
| 222 |
+
|
| 223 |
+
Spending some time fooling around with shape adjustments in PowerPoint is time
|
| 224 |
+
well spent to build an intuitive sense of how they behave. You also might want
|
| 225 |
+
to have ``opc-diag`` installed so you can look at the XML values that are
|
| 226 |
+
generated by different adjustments as a head start on developing your
|
| 227 |
+
adjustment code.
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
The following code formats a callout shape using its adjustments::
|
| 231 |
+
|
| 232 |
+
callout_sp = shapes.add_shape(
|
| 233 |
+
MSO_SHAPE.LINE_CALLOUT_2_ACCENT_BAR, left, top, width, height
|
| 234 |
+
)
|
| 235 |
+
|
| 236 |
+
# get the callout line coming out of the right place
|
| 237 |
+
adjs = callout_sp.adjustments
|
| 238 |
+
adjs[0] = 0.5 # vert pos of junction in margin line, 0 is top
|
| 239 |
+
adjs[1] = 0.0 # horz pos of margin ln wrt shape width, 0 is left side
|
| 240 |
+
adjs[2] = 0.5 # vert pos of elbow wrt margin line, 0 is top
|
| 241 |
+
adjs[3] = -0.1 # horz pos of elbow wrt shape width, 0 is margin line
|
| 242 |
+
adjs[4] = 3.0 # vert pos of line end wrt shape height, 0 is top
|
| 243 |
+
a5 = adjs[3] - (adjs[4] - adjs[0]) * height/width
|
| 244 |
+
adjs[5] = a5 # horz pos of elbow wrt shape width, 0 is margin line
|
| 245 |
+
|
| 246 |
+
# rotate 45 degrees counter-clockwise
|
| 247 |
+
callout_sp.rotation = -45.0
|
tasks/tasksmith-74f059424102/tests/source/docs/user/charts.rst
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Working with charts
|
| 3 |
+
===================
|
| 4 |
+
|
| 5 |
+
|pp| supports adding charts and modifying existing ones. Most chart types
|
| 6 |
+
other than 3D types are supported.
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
Adding a chart
|
| 10 |
+
--------------
|
| 11 |
+
|
| 12 |
+
The following code adds a single-series column chart in a new presentation::
|
| 13 |
+
|
| 14 |
+
from pptx import Presentation
|
| 15 |
+
from pptx.chart.data import CategoryChartData
|
| 16 |
+
from pptx.enum.chart import XL_CHART_TYPE
|
| 17 |
+
from pptx.util import Inches
|
| 18 |
+
|
| 19 |
+
# create presentation with 1 slide ------
|
| 20 |
+
prs = Presentation()
|
| 21 |
+
slide = prs.slides.add_slide(prs.slide_layouts[5])
|
| 22 |
+
|
| 23 |
+
# define chart data ---------------------
|
| 24 |
+
chart_data = CategoryChartData()
|
| 25 |
+
chart_data.categories = ['East', 'West', 'Midwest']
|
| 26 |
+
chart_data.add_series('Series 1', (19.2, 21.4, 16.7))
|
| 27 |
+
|
| 28 |
+
# add chart to slide --------------------
|
| 29 |
+
x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
|
| 30 |
+
slide.shapes.add_chart(
|
| 31 |
+
XL_CHART_TYPE.COLUMN_CLUSTERED, x, y, cx, cy, chart_data
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
prs.save('chart-01.pptx')
|
| 35 |
+
|
| 36 |
+
.. image:: /_static/img/chart-01.png
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
Customizing things a bit
|
| 40 |
+
------------------------
|
| 41 |
+
|
| 42 |
+
The remaining code will leave out code we've already seen and only show
|
| 43 |
+
imports, for example, when they're used for the first time, just to keep the
|
| 44 |
+
focus on the new bits. Let's create a multi-series chart to use for these
|
| 45 |
+
examples::
|
| 46 |
+
|
| 47 |
+
chart_data = ChartData()
|
| 48 |
+
chart_data.categories = ['East', 'West', 'Midwest']
|
| 49 |
+
chart_data.add_series('Q1 Sales', (19.2, 21.4, 16.7))
|
| 50 |
+
chart_data.add_series('Q2 Sales', (22.3, 28.6, 15.2))
|
| 51 |
+
chart_data.add_series('Q3 Sales', (20.4, 26.3, 14.2))
|
| 52 |
+
|
| 53 |
+
graphic_frame = slide.shapes.add_chart(
|
| 54 |
+
XL_CHART_TYPE.COLUMN_CLUSTERED, x, y, cx, cy, chart_data
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
chart = graphic_frame.chart
|
| 58 |
+
|
| 59 |
+
.. image:: /_static/img/chart-02.png
|
| 60 |
+
|
| 61 |
+
Notice that we captured the shape reference returned by the
|
| 62 |
+
:meth:`~.SlideShapes.add_chart` call as ``graphic_frame`` and then extracted
|
| 63 |
+
the chart object from the graphic frame using its
|
| 64 |
+
:attr:`~.GraphicFrame.chart` property. We'll need the chart reference to get
|
| 65 |
+
to the properties we'll need in the next steps. The
|
| 66 |
+
:meth:`~.SlideShapes.add_chart` method doesn't directly return the chart
|
| 67 |
+
object. That's because a chart is not itself a shape. Rather it's a graphical
|
| 68 |
+
(DrawingML) object *contained* in the graphic frame shape. Tables work this
|
| 69 |
+
way too, also being contained in a graphic frame shape.
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
XY and Bubble charts
|
| 73 |
+
--------------------
|
| 74 |
+
|
| 75 |
+
The charts so far use a *discrete* set of values for the independent variable
|
| 76 |
+
(the X axis, roughly speaking). These are perfect when your values fall into
|
| 77 |
+
a well-defined set of categories. However, there are many cases, particularly
|
| 78 |
+
in science and engineering, where the independent variable is a continuous
|
| 79 |
+
value, such as temperature or frequency. These are supported in PowerPoint by
|
| 80 |
+
XY (aka. scatter) charts. A bubble chart is essentially an XY chart where the
|
| 81 |
+
marker size is used to reflect an additional value, effectively adding
|
| 82 |
+
a third dimension to the chart.
|
| 83 |
+
|
| 84 |
+
Because the independent variable is continuous, in general, the series do not
|
| 85 |
+
all share the same X values. This requires a somewhat different data
|
| 86 |
+
structure and that is provided for by distinct |XyChartData| and
|
| 87 |
+
|BubbleChartData| objects used to specify the data behind charts of these
|
| 88 |
+
types::
|
| 89 |
+
|
| 90 |
+
chart_data = XyChartData()
|
| 91 |
+
|
| 92 |
+
series_1 = chart_data.add_series('Model 1')
|
| 93 |
+
series_1.add_data_point(0.7, 2.7)
|
| 94 |
+
series_1.add_data_point(1.8, 3.2)
|
| 95 |
+
series_1.add_data_point(2.6, 0.8)
|
| 96 |
+
|
| 97 |
+
series_2 = chart_data.add_series('Model 2')
|
| 98 |
+
series_2.add_data_point(1.3, 3.7)
|
| 99 |
+
series_2.add_data_point(2.7, 2.3)
|
| 100 |
+
series_2.add_data_point(1.6, 1.8)
|
| 101 |
+
|
| 102 |
+
chart = slide.shapes.add_chart(
|
| 103 |
+
XL_CHART_TYPE.XY_SCATTER, x, y, cx, cy, chart_data
|
| 104 |
+
).chart
|
| 105 |
+
|
| 106 |
+
.. image:: /_static/img/chart-08.png
|
| 107 |
+
|
| 108 |
+
Creation of a bubble chart is very similar, having an additional value for each data point that specifies the bubble size::
|
| 109 |
+
|
| 110 |
+
chart_data = BubbleChartData()
|
| 111 |
+
|
| 112 |
+
series_1 = chart_data.add_series('Series 1')
|
| 113 |
+
series_1.add_data_point(0.7, 2.7, 10)
|
| 114 |
+
series_1.add_data_point(1.8, 3.2, 4)
|
| 115 |
+
series_1.add_data_point(2.6, 0.8, 8)
|
| 116 |
+
|
| 117 |
+
chart = slide.shapes.add_chart(
|
| 118 |
+
XL_CHART_TYPE.BUBBLE, x, y, cx, cy, chart_data
|
| 119 |
+
).chart
|
| 120 |
+
|
| 121 |
+
.. image:: /_static/img/chart-09.png
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
Axes
|
| 126 |
+
----
|
| 127 |
+
|
| 128 |
+
Let's change up the category and value axes a bit::
|
| 129 |
+
|
| 130 |
+
from pptx.enum.chart import XL_TICK_MARK
|
| 131 |
+
from pptx.util import Pt
|
| 132 |
+
|
| 133 |
+
category_axis = chart.category_axis
|
| 134 |
+
category_axis.has_major_gridlines = True
|
| 135 |
+
category_axis.minor_tick_mark = XL_TICK_MARK.OUTSIDE
|
| 136 |
+
category_axis.tick_labels.font.italic = True
|
| 137 |
+
category_axis.tick_labels.font.size = Pt(24)
|
| 138 |
+
|
| 139 |
+
value_axis = chart.value_axis
|
| 140 |
+
value_axis.maximum_scale = 50.0
|
| 141 |
+
value_axis.minor_tick_mark = XL_TICK_MARK.OUTSIDE
|
| 142 |
+
value_axis.has_minor_gridlines = True
|
| 143 |
+
|
| 144 |
+
tick_labels = value_axis.tick_labels
|
| 145 |
+
tick_labels.number_format = '0"%"'
|
| 146 |
+
tick_labels.font.bold = True
|
| 147 |
+
tick_labels.font.size = Pt(14)
|
| 148 |
+
|
| 149 |
+
.. image:: /_static/img/chart-03.png
|
| 150 |
+
|
| 151 |
+
Okay, that was probably going a bit too far. But it gives us an idea of the
|
| 152 |
+
kinds of things we can do with the value and category axes. Let's undo this
|
| 153 |
+
part and go back to the version we had before.
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
Data Labels
|
| 157 |
+
-----------
|
| 158 |
+
|
| 159 |
+
Let's add some data labels so we can see exactly what the value for each bar
|
| 160 |
+
is::
|
| 161 |
+
|
| 162 |
+
from pptx.dml.color import RGBColor
|
| 163 |
+
from pptx.enum.chart import XL_LABEL_POSITION
|
| 164 |
+
|
| 165 |
+
plot = chart.plots[0]
|
| 166 |
+
plot.has_data_labels = True
|
| 167 |
+
data_labels = plot.data_labels
|
| 168 |
+
|
| 169 |
+
data_labels.font.size = Pt(13)
|
| 170 |
+
data_labels.font.color.rgb = RGBColor(0x0A, 0x42, 0x80)
|
| 171 |
+
data_labels.position = XL_LABEL_POSITION.INSIDE_END
|
| 172 |
+
|
| 173 |
+
.. image:: /_static/img/chart-04.png
|
| 174 |
+
|
| 175 |
+
Here we needed to access a Plot object to gain access to the data labels.
|
| 176 |
+
A plot is like a sub-chart, containing one or more series and drawn as
|
| 177 |
+
a particular chart type, like column or line. This distinction is needed for
|
| 178 |
+
charts that combine more than one type, like a line chart appearing on top of
|
| 179 |
+
a column chart. A chart like this would have two plot objects, one for the
|
| 180 |
+
series appearing as columns and the other for the lines. Most charts only
|
| 181 |
+
have a single plot and |pp| doesn't yet support creating multi-plot charts,
|
| 182 |
+
but you can access multiple plots on a chart that already has them.
|
| 183 |
+
|
| 184 |
+
In the Microsoft API, the name *ChartGroup* is used for this object. I found
|
| 185 |
+
that term confusing for a long time while I was learning about MS Office
|
| 186 |
+
charts so I chose the name Plot for that object in |pp|.
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
Legend
|
| 190 |
+
------
|
| 191 |
+
|
| 192 |
+
A legend is often useful to have on a chart, to give a name to each series
|
| 193 |
+
and help a reader tell which one is which::
|
| 194 |
+
|
| 195 |
+
from pptx.enum.chart import XL_LEGEND_POSITION
|
| 196 |
+
|
| 197 |
+
chart.has_legend = True
|
| 198 |
+
chart.legend.position = XL_LEGEND_POSITION.RIGHT
|
| 199 |
+
chart.legend.include_in_layout = False
|
| 200 |
+
|
| 201 |
+
.. image:: /_static/img/chart-05.png
|
| 202 |
+
|
| 203 |
+
Nice! Okay, let's try some other chart types.
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
Line Chart
|
| 207 |
+
----------
|
| 208 |
+
|
| 209 |
+
A line chart is added pretty much the same way as a bar or column chart, the
|
| 210 |
+
main difference being the chart type provided in the :meth:`add_chart` call::
|
| 211 |
+
|
| 212 |
+
chart_data = ChartData()
|
| 213 |
+
chart_data.categories = ['Q1 Sales', 'Q2 Sales', 'Q3 Sales']
|
| 214 |
+
chart_data.add_series('West', (32.2, 28.4, 34.7))
|
| 215 |
+
chart_data.add_series('East', (24.3, 30.6, 20.2))
|
| 216 |
+
chart_data.add_series('Midwest', (20.4, 18.3, 26.2))
|
| 217 |
+
|
| 218 |
+
x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
|
| 219 |
+
chart = slide.shapes.add_chart(
|
| 220 |
+
XL_CHART_TYPE.LINE, x, y, cx, cy, chart_data
|
| 221 |
+
).chart
|
| 222 |
+
|
| 223 |
+
chart.has_legend = True
|
| 224 |
+
chart.legend.include_in_layout = False
|
| 225 |
+
chart.series[0].smooth = True
|
| 226 |
+
|
| 227 |
+
.. image:: /_static/img/chart-06.png
|
| 228 |
+
|
| 229 |
+
I switched the categories and series data here to better suit a line chart.
|
| 230 |
+
You can see the line for the "West" region is *smoothed* into a curve while
|
| 231 |
+
the other two have their points connected with straight line segments.
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
Pie Chart
|
| 235 |
+
---------
|
| 236 |
+
|
| 237 |
+
A pie chart is a little special in that it only ever has a single series and
|
| 238 |
+
doesn't have any axes::
|
| 239 |
+
|
| 240 |
+
chart_data = ChartData()
|
| 241 |
+
chart_data.categories = ['West', 'East', 'North', 'South', 'Other']
|
| 242 |
+
chart_data.add_series('Series 1', (0.135, 0.324, 0.180, 0.235, 0.126))
|
| 243 |
+
|
| 244 |
+
chart = slide.shapes.add_chart(
|
| 245 |
+
XL_CHART_TYPE.PIE, x, y, cx, cy, chart_data
|
| 246 |
+
).chart
|
| 247 |
+
|
| 248 |
+
chart.has_legend = True
|
| 249 |
+
chart.legend.position = XL_LEGEND_POSITION.BOTTOM
|
| 250 |
+
chart.legend.include_in_layout = False
|
| 251 |
+
|
| 252 |
+
chart.plots[0].has_data_labels = True
|
| 253 |
+
data_labels = chart.plots[0].data_labels
|
| 254 |
+
data_labels.number_format = '0%'
|
| 255 |
+
data_labels.position = XL_LABEL_POSITION.OUTSIDE_END
|
| 256 |
+
|
| 257 |
+
.. image:: /_static/img/chart-07.png
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
Odds & Ends
|
| 261 |
+
-----------
|
| 262 |
+
|
| 263 |
+
This should be enough to get you started with adding charts to your
|
| 264 |
+
presentation with |pp|. There are more details in the API documentation for
|
| 265 |
+
charts here: :ref:`chart-api`
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
About colors
|
| 269 |
+
~~~~~~~~~~~~
|
| 270 |
+
|
| 271 |
+
By default, the colors assigned to each series in a chart are the theme
|
| 272 |
+
colors Accent 1 through Accent 6, in that order. If you have more than six
|
| 273 |
+
series, darker and lighter versions of those same colors are used. While it's
|
| 274 |
+
possible to assign specific colors to data points (bar, line, pie segment,
|
| 275 |
+
etc.) for at least some chart types, the best strategy to start with is
|
| 276 |
+
changing the theme colors in your starting "template" presentation.
|
tasks/tasksmith-74f059424102/tests/source/docs/user/concepts.rst
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Concepts
|
| 2 |
+
========
|
| 3 |
+
|
| 4 |
+
|pp| is completely object-oriented, and in general any operations you perform
|
| 5 |
+
with it will be on an object. The root object for a presentation is
|
| 6 |
+
|Presentation|. API details are provided on the modules pages, but here are
|
| 7 |
+
some basics to get you started, especially some relationships you might find
|
| 8 |
+
surprising at first.
|
| 9 |
+
|
| 10 |
+
A presentation is loaded by constructing a new |Presentation| instance,
|
| 11 |
+
passing in the path to a presentation to be loaded::
|
| 12 |
+
|
| 13 |
+
from pptx import Presentation
|
| 14 |
+
|
| 15 |
+
path = 'slide-deck-foo.pptx'
|
| 16 |
+
prs = Presentation(path)
|
| 17 |
+
|
| 18 |
+
|pp| also contains a default template, and if you construct a |Presentation|
|
| 19 |
+
instance without a path, a presentation based on that default template is
|
| 20 |
+
loaded. This can be handy when you want to get started quickly, and most of the
|
| 21 |
+
examples in this documentation use the default template.::
|
| 22 |
+
|
| 23 |
+
# start with default presentation
|
| 24 |
+
prs = Presentation()
|
| 25 |
+
|
| 26 |
+
Note that there is currently no distinction between templates and presentations
|
| 27 |
+
in |pp| as there is in the PowerPoint® client, there are only presentations. To
|
| 28 |
+
use a "template" for a presentation you simply create a presentation with all
|
| 29 |
+
the styles, logo, and layouts you want, delete all the slides (or leave some in
|
| 30 |
+
if it suits), and then load that as your starting place.
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
Slide masters
|
| 34 |
+
-------------
|
| 35 |
+
|
| 36 |
+
A presentation has a list of slide masters and a list of slides. Let's start
|
| 37 |
+
with a discussion of the slide masters.
|
| 38 |
+
|
| 39 |
+
One fact some find surprising (I did) is that a presentation file can have
|
| 40 |
+
more than one slide master. It's quite uncommon in my experience to find
|
| 41 |
+
presentations that make use of this feature, but it's entirely supported. The
|
| 42 |
+
only time I've seen this happen is when slides from a "foreign" presentation
|
| 43 |
+
are pasted into another deck; if you want the formatting and backgrounds from
|
| 44 |
+
the other deck to be preserved on the pasted-in slides, the slide master and
|
| 45 |
+
its slide layouts need to come with. Consequently, the presentation needs to
|
| 46 |
+
maintain a list of slide masters, not just a single one, even though perhaps
|
| 47 |
+
99% of the time you only ever use the one. To make things a little easier for
|
| 48 |
+
the 99% situation, you can refer to the first slide master as though it were
|
| 49 |
+
the only one::
|
| 50 |
+
|
| 51 |
+
prs = Presentation()
|
| 52 |
+
slide_master = prs.slide_masters[0]
|
| 53 |
+
# is equivalent to
|
| 54 |
+
slide_master = prs.slide_master
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
Slide layouts
|
| 58 |
+
-------------
|
| 59 |
+
|
| 60 |
+
Another fact that might be surprising is that slide layouts belong to a slide
|
| 61 |
+
master, not directly to a presentation, so normally you have to access the
|
| 62 |
+
slide layouts via their slide master. Since this is subject to the same 99%
|
| 63 |
+
situation described above, the slide layouts belonging to the first slide
|
| 64 |
+
master can also be accessed directly from the presentation via syntactic
|
| 65 |
+
sugar::
|
| 66 |
+
|
| 67 |
+
prs = Presentation()
|
| 68 |
+
title_slide_layout = prs.slide_masters[0].slide_layouts[0]
|
| 69 |
+
# is equivalent to:
|
| 70 |
+
title_slide_layout = prs.slide_layouts[0]
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
Slides
|
| 74 |
+
------
|
| 75 |
+
|
| 76 |
+
The slides in a presentation belong to the presentation object and are
|
| 77 |
+
accessed using the ``slides`` attribute::
|
| 78 |
+
|
| 79 |
+
prs = Presentation(path)
|
| 80 |
+
first_slide = prs.slides[0]
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
Adding a slide
|
| 84 |
+
^^^^^^^^^^^^^^
|
| 85 |
+
|
| 86 |
+
Adding a slide is accomplished by calling the :meth:`add_slide` method on the
|
| 87 |
+
:attr:`slides` attribute of the presentation. A slide layout must be passed
|
| 88 |
+
in to specify the layout the new slide should take on::
|
| 89 |
+
|
| 90 |
+
prs = Presentation()
|
| 91 |
+
title_slide_layout = prs.slide_layouts[0]
|
| 92 |
+
new_slide = prs.slides.add_slide(title_slide_layout)
|
tasks/tasksmith-74f059424102/tests/source/docs/user/install.rst
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. _install:
|
| 2 |
+
|
| 3 |
+
Installing
|
| 4 |
+
==========
|
| 5 |
+
|
| 6 |
+
|pp| is hosted on PyPI, so installing with `pip` is simple::
|
| 7 |
+
|
| 8 |
+
pip install python-pptx
|
| 9 |
+
|
| 10 |
+
|pp| depends on the ``lxml`` package and ``Pillow``, the modern version of
|
| 11 |
+
the Python Imaging Library (``PIL``). The charting features depend on
|
| 12 |
+
``XlsxWriter``. Both ``pip`` and ``easy_install`` will take care of
|
| 13 |
+
satisfying these dependencies for you, but if you use the ``setup.py``
|
| 14 |
+
installation method you will need to install the dependencies yourself.
|
| 15 |
+
|
| 16 |
+
Currently |pp| requires Python 2.7 or 3.3 or later. The tests are run against 2.7 and
|
| 17 |
+
3.8 on Travis CI.
|
| 18 |
+
|
| 19 |
+
Dependencies
|
| 20 |
+
------------
|
| 21 |
+
|
| 22 |
+
* Python 2.6, 2.7, 3.3 or later
|
| 23 |
+
* lxml
|
| 24 |
+
* Pillow
|
| 25 |
+
* XlsxWriter (to use charting features)
|
tasks/tasksmith-74f059424102/tests/source/docs/user/intro.rst
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. _introduction:
|
| 2 |
+
|
| 3 |
+
Introduction
|
| 4 |
+
============
|
| 5 |
+
|
| 6 |
+
*python-pptx* is a Python library for creating and updating PowerPoint (.pptx)
|
| 7 |
+
files.
|
| 8 |
+
|
| 9 |
+
A typical use would be generating a customized PowerPoint presentation from
|
| 10 |
+
database content, downloadble by clicking a link in a web application. Several
|
| 11 |
+
developers have used it to automate production of presentation-ready
|
| 12 |
+
engineering status reports based on information held in their work management
|
| 13 |
+
system. It could also be used for making bulk updates to a library of
|
| 14 |
+
presentations or simply to automate the production of a slide or two that would
|
| 15 |
+
be tedious to get right by hand.
|
| 16 |
+
|
| 17 |
+
This user guide is tutorial in nature, introducing concepts along with code
|
| 18 |
+
examples that I hope will allow you to learn what you need while addressing
|
| 19 |
+
the real-life PowerPoint challenges you're working on.
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
python-pptx License
|
| 23 |
+
-------------------
|
| 24 |
+
|
| 25 |
+
.. include:: ../../LICENSE
|
tasks/tasksmith-74f059424102/tests/source/docs/user/notes.rst
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Working with Notes Slides
|
| 3 |
+
=========================
|
| 4 |
+
|
| 5 |
+
A slide can have notes associated with it. These are perhaps most commonly
|
| 6 |
+
encountered in the notes pane, below the slide in PowerPoint "Normal" view
|
| 7 |
+
where it may say "Click to add notes".
|
| 8 |
+
|
| 9 |
+
The notes added here appear each time that slide is present in the main pane.
|
| 10 |
+
They also appear in *Presenter View* and in *Notes Page* view, both available
|
| 11 |
+
from the menu.
|
| 12 |
+
|
| 13 |
+
Notes can contain rich text, commonly bullets, bold, varying font sizes and
|
| 14 |
+
colors, etc. The Notes Page view has somewhat more powerful tools for editing
|
| 15 |
+
the notes text than the note pane in Normal view.
|
| 16 |
+
|
| 17 |
+
In the API and the underlying XML, the object that contains the text is known
|
| 18 |
+
as a *Notes Slide*. This is because internally, a notes slide is actually
|
| 19 |
+
a specialized instance of a slide. It contains shapes, many of which are
|
| 20 |
+
placeholders, and allows inserting of new shapes such as pictures (a logo
|
| 21 |
+
perhaps) auto shapes, tables, and charts. Consequently, working with a notes
|
| 22 |
+
slide is very much like working with a regular slide.
|
| 23 |
+
|
| 24 |
+
Each slide can have zero or one notes slide. A notes slide is created the
|
| 25 |
+
first time it is used, generally perhaps by adding notes text to a slide.
|
| 26 |
+
Once created, it stays, even if all the text is deleted.
|
| 27 |
+
|
| 28 |
+
The Notes Master
|
| 29 |
+
----------------
|
| 30 |
+
|
| 31 |
+
A new notes slide is created using the *Notes Master* as a template.
|
| 32 |
+
A presentation has no notes master when newly created in PowerPoint. One is
|
| 33 |
+
created according to a PowerPoint-internal preset default the first time it
|
| 34 |
+
is needed, which is generally when the first notes slide is created. It's
|
| 35 |
+
possible one can also be created by entering the Notes Master view and almost
|
| 36 |
+
certainly is created by editing the master found there (haven't tried it
|
| 37 |
+
though). A presentation can have at most one notes master.
|
| 38 |
+
|
| 39 |
+
The notes master governs the look and feel of notes pages, which can be
|
| 40 |
+
viewed on-screen but are really designed for printing out. So if you want
|
| 41 |
+
your notes page print-outs to look different from the default, you can make
|
| 42 |
+
a lot of customizations by editing the notes master. You access the notes
|
| 43 |
+
master editor using View > Master > Notes Master on the menu (on my version
|
| 44 |
+
at least). Notes slides created using |pp| will have the look and feel of the
|
| 45 |
+
notes master in the presentation file you opened to create the presentation.
|
| 46 |
+
|
| 47 |
+
On creation, certain placeholders (slide image, notes, slide number) are
|
| 48 |
+
copied from the notes master onto the new notes slide (if they have not been
|
| 49 |
+
removed from the master). These "cloned" placeholders inherit position, size,
|
| 50 |
+
and formatting from their corresponding notes master placeholder. If the
|
| 51 |
+
position, size, or formatting of a notes slide placeholder is changed, the
|
| 52 |
+
changed property is no long inherited (unchanged properties, however,
|
| 53 |
+
continue to be inherited).
|
| 54 |
+
|
| 55 |
+
Notes Slide basics
|
| 56 |
+
------------------
|
| 57 |
+
|
| 58 |
+
Enough talk, let's show some code. Let's say you have a slide you're working
|
| 59 |
+
with and you want to see if it has a notes slide yet::
|
| 60 |
+
|
| 61 |
+
>>> slide.has_notes_slide
|
| 62 |
+
False
|
| 63 |
+
|
| 64 |
+
Ok, not yet. Good. Let's add some notes::
|
| 65 |
+
|
| 66 |
+
>>> notes_slide = slide.notes_slide
|
| 67 |
+
>>> text_frame = notes_slide.notes_text_frame
|
| 68 |
+
>>> text_frame.text = 'foobar'
|
| 69 |
+
|
| 70 |
+
Alright, simple enough. Let's look at what happened here:
|
| 71 |
+
|
| 72 |
+
* ``slide.notes_slide`` gave us the notes slide. In this case, it first
|
| 73 |
+
created that notes slide based on the notes master. If there was no notes
|
| 74 |
+
master, it created that too. So a lot of things can happen behind the
|
| 75 |
+
scenes with this call the first time you call it, but if we called it again
|
| 76 |
+
it would just give us back the reference to the same notes slide, which it
|
| 77 |
+
caches, once retrieved.
|
| 78 |
+
|
| 79 |
+
* ``notes_slide.notes_text_frame`` gave us the |TextFrame| object that
|
| 80 |
+
contains the actual notes. The reason it's not just
|
| 81 |
+
``notes_slide.text_frame`` is that there are potentially more than one. What
|
| 82 |
+
this is doing behind the scenes is finding the placeholder shape that
|
| 83 |
+
contains the notes (as opposed to the slide image, header, slide number,
|
| 84 |
+
etc.) and giving us *that* particular text frame.
|
| 85 |
+
|
| 86 |
+
* A text frame in a notes slide works the same as one in a regular slide.
|
| 87 |
+
More precisely, a text frame on a shape in a notes slide works the same as
|
| 88 |
+
in any other shape. We used the ``.text`` property to quickly pop some text
|
| 89 |
+
in there.
|
| 90 |
+
|
| 91 |
+
Using the text frame, you can add an arbitrary amount of text, formatted
|
| 92 |
+
however you want.
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
Notes Slide Placeholders
|
| 96 |
+
------------------------
|
| 97 |
+
|
| 98 |
+
What we haven't explicitly seen so far is the shapes on a slide master. It's
|
| 99 |
+
easy to get started with that::
|
| 100 |
+
|
| 101 |
+
>>> notes_placeholder = notes_slide.notes_placeholder
|
| 102 |
+
|
| 103 |
+
This notes placeholder is just like a body placeholder we saw a couple
|
| 104 |
+
sections back. You can change its position, size, and many other attributes,
|
| 105 |
+
as well as get at its text via its text frame.
|
| 106 |
+
|
| 107 |
+
You can also access the other placeholders::
|
| 108 |
+
|
| 109 |
+
>>> for placeholder in notes_slide.placeholders:
|
| 110 |
+
... print placeholder.placeholder_format.type
|
| 111 |
+
...
|
| 112 |
+
SLIDE_IMAGE (101)
|
| 113 |
+
BODY (2)
|
| 114 |
+
SLIDE_NUMBER (13)
|
| 115 |
+
|
| 116 |
+
and also the shapes (a superset of the placeholders)::
|
| 117 |
+
|
| 118 |
+
>>> for shape in notes_slide.shapes:
|
| 119 |
+
... print shape
|
| 120 |
+
...
|
| 121 |
+
<pptx.shapes.placeholder.NotesSlidePlaceholder object at 0x11091e890>
|
| 122 |
+
<pptx.shapes.placeholder.NotesSlidePlaceholder object at 0x11091e750>
|
| 123 |
+
<pptx.shapes.placeholder.NotesSlidePlaceholder object at 0x11091e990>
|
| 124 |
+
|
| 125 |
+
In the common case, the notes slide contains only placeholders. However, if
|
| 126 |
+
you added an image, for example, to the notes slide, that would show up as
|
| 127 |
+
well. Note that if you added that image to the notes master, perhaps a logo,
|
| 128 |
+
it would appear on the notes slide "visually", but would not appear as
|
| 129 |
+
a shape in the notes slide shape collection. Rather, it is visually
|
| 130 |
+
"inherited" from the notes master.
|
tasks/tasksmith-74f059424102/tests/source/docs/user/placeholders-understanding.rst
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Understanding placeholders
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
Intuitively, a placeholder is a pre-formatted container into which content
|
| 6 |
+
can be placed. By providing pre-set formatting to its content, it places many
|
| 7 |
+
of the formatting choices in the hands of the template designer while
|
| 8 |
+
allowing the end-user to concentrate on the actual content. This speeds the
|
| 9 |
+
presentation development process while encouraging visual consistency in
|
| 10 |
+
slides created from the same template.
|
| 11 |
+
|
| 12 |
+
While their typical end-user behaviors are relatively simple, the structures
|
| 13 |
+
that support their operation are more complex. This page is for those who
|
| 14 |
+
want to better understand the architecture of the placeholder subsystem and
|
| 15 |
+
perhaps be less prone to confusion at its sometimes puzzling behavior. If you
|
| 16 |
+
don't care why they work and just want to know how to work with them, you may
|
| 17 |
+
want to skip forward to the following page :ref:`placeholders-using`.
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
A placeholder is a shape
|
| 21 |
+
------------------------
|
| 22 |
+
|
| 23 |
+
Placeholders are an orthogonal category of shape, which is to say multiple
|
| 24 |
+
shape types can be placeholders. In particular, the auto shape (`p:sp`
|
| 25 |
+
element), picture (`p:pic` element), and graphic frame (`p:graphicFrame`)
|
| 26 |
+
shape types can be a placeholder. The group shape (`p:grpSp`), connector
|
| 27 |
+
(`p:cxnSp`), and content part (`p:contentPart`) shapes cannot be
|
| 28 |
+
a placeholder. A graphic frame placeholder can contain a table, a chart, or
|
| 29 |
+
SmartArt.
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
Placeholder types
|
| 33 |
+
-----------------
|
| 34 |
+
|
| 35 |
+
There are 18 types of placeholder.
|
| 36 |
+
|
| 37 |
+
Title, Center Title, Subtitle, Body
|
| 38 |
+
These placeholders typically appear on a conventional "word chart"
|
| 39 |
+
containing text only, often organized as a title and a series of bullet
|
| 40 |
+
points. All of these placeholders can accept text only.
|
| 41 |
+
|
| 42 |
+
Content
|
| 43 |
+
This multi-purpose placeholder is the most commonly used for the body of
|
| 44 |
+
a slide. When unpopulated, it displays 6 buttons to allow insertion of
|
| 45 |
+
a table, a chart, SmartArt, a picture, clip art, or a media clip.
|
| 46 |
+
|
| 47 |
+
Picture, Clip Art
|
| 48 |
+
These both allow insertion of an image. The insert button on a clip art
|
| 49 |
+
placeholder brings up the clip art gallery rather than an image file
|
| 50 |
+
chooser, but otherwise these behave the same.
|
| 51 |
+
|
| 52 |
+
Chart, Table, Smart Art
|
| 53 |
+
These three allow the respective type of rich graphical content to be
|
| 54 |
+
inserted.
|
| 55 |
+
|
| 56 |
+
Media Clip
|
| 57 |
+
Allows a video or sound recording to be inserted.
|
| 58 |
+
|
| 59 |
+
Date, Footer, Slide Number
|
| 60 |
+
These three appear on most slide masters and slide layouts, but do not
|
| 61 |
+
behave as most users would expect. These also commonly appear on the Notes
|
| 62 |
+
Master and Handout Master.
|
| 63 |
+
|
| 64 |
+
Header
|
| 65 |
+
Only valid on the Notes Master and Handout Master.
|
| 66 |
+
|
| 67 |
+
Vertical Body, Vertical Object, Vertical Title
|
| 68 |
+
Used with vertically oriented languages such as Japanese.
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
Unpopulated vs. populated
|
| 72 |
+
-------------------------
|
| 73 |
+
|
| 74 |
+
A placeholder on a slide can be empty or filled. This is most evident with
|
| 75 |
+
a picture placeholder. When unpopulated, a placeholder displays customizable
|
| 76 |
+
prompt text. A rich content placeholder will also display one or more content
|
| 77 |
+
insertion buttons when empty.
|
| 78 |
+
|
| 79 |
+
A text-only placeholder enters "populated" mode when the first character of
|
| 80 |
+
text is entered and returns to "unpopulated" mode when the last character of
|
| 81 |
+
text is removed. A rich-content placeholder enters populated mode when
|
| 82 |
+
content such as a picture is inserted and returns to unpopulated mode when
|
| 83 |
+
that content is deleted. In order to delete a populated placeholder, the
|
| 84 |
+
shape must be deleted *twice*. The first delete removes the content and
|
| 85 |
+
restores the placeholder to unpopulated mode. An additional delete will
|
| 86 |
+
remove the placeholder itself. A deleted placeholder can be restored by
|
| 87 |
+
reapplying the layout.
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
Placholders inherit
|
| 91 |
+
-------------------
|
| 92 |
+
|
| 93 |
+
A placeholder appearing on a slide is only part of the overall placeholder
|
| 94 |
+
mechanism. Placeholder behavior requires three different categories of
|
| 95 |
+
placeholder shape; those that exist on a slide master, those on a slide
|
| 96 |
+
layout, and those that ultimately appear on a slide in a presentation.
|
| 97 |
+
|
| 98 |
+
These three categories of placeholder participate in a property inheritance
|
| 99 |
+
hierarchy, either as an inheritor, an inheritee, or both. Placeholder shapes
|
| 100 |
+
on masters are inheritees only. Conversely placeholder shapes on slides are
|
| 101 |
+
inheritors only. Placeholders on slide layouts are both, a possible inheritor
|
| 102 |
+
from a slide master placeholder and an inheritee to placeholders on slides
|
| 103 |
+
linked to that layout.
|
| 104 |
+
|
| 105 |
+
A layout inherits from its master differently than a slide inherits from
|
| 106 |
+
its layout. A layout placeholder inherits from the master placeholder sharing
|
| 107 |
+
the same type. A slide placeholder inherits from the layout placeholder
|
| 108 |
+
having the same `idx` value.
|
| 109 |
+
|
| 110 |
+
In general, all formatting properties are inherited from the "parent"
|
| 111 |
+
placeholder. This includes position and size as well as fill, line, and font.
|
| 112 |
+
Any directly applied formatting overrides the corresponding inherited value.
|
| 113 |
+
Directly applied formatting can be removed be reapplying the layout.
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
Glossary
|
| 117 |
+
--------
|
| 118 |
+
|
| 119 |
+
placeholder shape
|
| 120 |
+
A shape on a slide that inherits from a layout placeholder.
|
| 121 |
+
|
| 122 |
+
layout placeholder
|
| 123 |
+
a shorthand name for the placeholder shape on the slide layout from which
|
| 124 |
+
a particular placeholder on a slide inherits shape properties
|
| 125 |
+
|
| 126 |
+
master placeholder
|
| 127 |
+
the placeholder shape on the slide master which a layout placeholder
|
| 128 |
+
inherits from, if any.
|
tasks/tasksmith-74f059424102/tests/source/docs/user/placeholders-using.rst
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. _placeholders-using:
|
| 2 |
+
|
| 3 |
+
Working with placeholders
|
| 4 |
+
=========================
|
| 5 |
+
|
| 6 |
+
Placeholders can make adding content a lot easier. If you've ever added a new
|
| 7 |
+
textbox to a slide from scratch and noticed how many adjustments it took to
|
| 8 |
+
get it the way you wanted you understand why. The placeholder is in the right
|
| 9 |
+
position with the right font size, paragraph alignment, bullet style, etc.,
|
| 10 |
+
etc. Basically you can just click and type in some text and you've got
|
| 11 |
+
a slide.
|
| 12 |
+
|
| 13 |
+
A placeholder can be also be used to place a rich-content object on a slide.
|
| 14 |
+
A picture, table, or chart can each be inserted into a placeholder and so
|
| 15 |
+
take on the position and size of the placeholder, as well as certain
|
| 16 |
+
of its formatting attributes.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
Access a placeholder
|
| 20 |
+
--------------------
|
| 21 |
+
|
| 22 |
+
Every placeholder is also a shape, and so can be accessed using the
|
| 23 |
+
:attr:`~.Slide.shapes` property of a slide. However, when looking for
|
| 24 |
+
a particular placeholder, the :attr:`~.Slide.placeholders` property can make
|
| 25 |
+
things easier.
|
| 26 |
+
|
| 27 |
+
The most reliable way to access a known placeholder is by its
|
| 28 |
+
:attr:`~.PlaceholderFormat.idx` value. The :attr:`idx` value of a placeholder
|
| 29 |
+
is the integer key of the slide layout placeholder it inherits properties
|
| 30 |
+
from. As such, it remains stable throughout the life of the slide and will be
|
| 31 |
+
the same for any slide created using that layout.
|
| 32 |
+
|
| 33 |
+
It's usually easy enough to take a look at the placeholders on a slide and
|
| 34 |
+
pick out the one you want::
|
| 35 |
+
|
| 36 |
+
>>> prs = Presentation()
|
| 37 |
+
>>> slide = prs.slides.add_slide(prs.slide_layouts[8])
|
| 38 |
+
>>> for shape in slide.placeholders:
|
| 39 |
+
... print('%d %s' % (shape.placeholder_format.idx, shape.name))
|
| 40 |
+
...
|
| 41 |
+
0 Title 1
|
| 42 |
+
1 Picture Placeholder 2
|
| 43 |
+
2 Text Placeholder 3
|
| 44 |
+
|
| 45 |
+
... then, having the known index in hand, to access it directly::
|
| 46 |
+
|
| 47 |
+
>>> slide.placeholders[1]
|
| 48 |
+
<pptx.parts.slide.PicturePlaceholder object at 0x10d094590>
|
| 49 |
+
>>> slide.placeholders[2].name
|
| 50 |
+
'Text Placeholder 3'
|
| 51 |
+
|
| 52 |
+
.. note:: Item access on the placeholders collection is like that of
|
| 53 |
+
a dictionary rather than a list. While the key used above is an integer,
|
| 54 |
+
the lookup is on `idx` values, not position in a sequence. If the provided
|
| 55 |
+
value does not match the `idx` value of one of the placeholders,
|
| 56 |
+
|KeyError| will be raised. `idx` values are not necessarily contiguous.
|
| 57 |
+
|
| 58 |
+
In general, the :attr:`idx` value of a placeholder from a built-in slide
|
| 59 |
+
layout (one provided with PowerPoint) will be between 0 and 5. The title
|
| 60 |
+
placeholder will always have :attr:`idx` 0 if present and any other
|
| 61 |
+
placeholders will follow in sequence, top to bottom and left to right.
|
| 62 |
+
A placeholder added to a slide layout by a user in PowerPoint will receive an
|
| 63 |
+
:attr:`idx` value starting at 10.
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
Identify and Characterize a placeholder
|
| 67 |
+
---------------------------------------
|
| 68 |
+
|
| 69 |
+
A placeholder behaves differently that other shapes in some ways. In
|
| 70 |
+
particular, the value of its :attr:`~.BaseShape.shape_type` attribute is
|
| 71 |
+
unconditionally ``MSO_SHAPE_TYPE.PLACEHOLDER`` regardless of what type of
|
| 72 |
+
placeholder it is or what type of content it contains::
|
| 73 |
+
|
| 74 |
+
>>> prs = Presentation()
|
| 75 |
+
>>> slide = prs.slides.add_slide(prs.slide_layouts[8])
|
| 76 |
+
>>> for shape in slide.shapes:
|
| 77 |
+
... print('%s' % shape.shape_type)
|
| 78 |
+
...
|
| 79 |
+
PLACEHOLDER (14)
|
| 80 |
+
PLACEHOLDER (14)
|
| 81 |
+
PLACEHOLDER (14)
|
| 82 |
+
|
| 83 |
+
To find out more, it's necessary to inspect the contents of the placeholder's
|
| 84 |
+
:attr:`~.BaseShape.placeholder_format` attribute. All shapes have this
|
| 85 |
+
attribute, but accessing it on a non-placeholder shape raises |ValueError|.
|
| 86 |
+
The :attr:`~.BaseShape.is_placeholder` attribute can be used to determine
|
| 87 |
+
whether a shape is a placeholder::
|
| 88 |
+
|
| 89 |
+
>>> for shape in slide.shapes:
|
| 90 |
+
... if shape.is_placeholder:
|
| 91 |
+
... phf = shape.placeholder_format
|
| 92 |
+
... print('%d, %s' % (phf.idx, phf.type))
|
| 93 |
+
...
|
| 94 |
+
0, TITLE (1)
|
| 95 |
+
1, PICTURE (18)
|
| 96 |
+
2, BODY (2)
|
| 97 |
+
|
| 98 |
+
Another way a placeholder acts differently is that it inherits its position
|
| 99 |
+
and size from its layout placeholder. This inheritance is overridden if the
|
| 100 |
+
position and size of a placeholder are changed.
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
Insert content into a placeholder
|
| 104 |
+
---------------------------------
|
| 105 |
+
|
| 106 |
+
Certain placeholder types have specialized methods for inserting content. In
|
| 107 |
+
the current release, the `picture`, `table`, and `chart` placeholders have
|
| 108 |
+
content insertion methods. Text can be inserted into `title` and `body`
|
| 109 |
+
placeholders in the same way text is inserted into an auto shape.
|
| 110 |
+
|
| 111 |
+
:meth:`.PicturePlaceholder.insert_picture`
|
| 112 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 113 |
+
|
| 114 |
+
The picture placeholder has an :meth:`~.PicturePlaceholder.insert_picture`
|
| 115 |
+
method::
|
| 116 |
+
|
| 117 |
+
>>> prs = Presentation()
|
| 118 |
+
>>> slide = prs.slides.add_slide(prs.slide_layouts[8])
|
| 119 |
+
>>> placeholder = slide.placeholders[1] # idx key, not position
|
| 120 |
+
>>> placeholder.name
|
| 121 |
+
'Picture Placeholder 2'
|
| 122 |
+
>>> placeholder.placeholder_format.type
|
| 123 |
+
PICTURE (18)
|
| 124 |
+
>>> picture = placeholder.insert_picture('my-image.png')
|
| 125 |
+
|
| 126 |
+
.. note:: A reference to a picture placeholder becomes invalid after its
|
| 127 |
+
:meth:`~.PicturePlaceholder.insert_picture` method is called. This is
|
| 128 |
+
because the process of inserting a picture replaces the original `p:sp`
|
| 129 |
+
XML element with a new `p:pic` element containing the picture. Any attempt
|
| 130 |
+
to use the original placeholder reference after the call will raise
|
| 131 |
+
|AttributeError|. The new placeholder is the return value of the
|
| 132 |
+
:meth:`insert_picture` call and may also be obtained from the placeholders
|
| 133 |
+
collection using the same `idx` key.
|
| 134 |
+
|
| 135 |
+
A picture inserted in this way is stretched proportionately and cropped to
|
| 136 |
+
fill the entire placeholder. Best results are achieved when the aspect ratio
|
| 137 |
+
of the source image and placeholder are the same. If the picture is taller
|
| 138 |
+
in aspect than the placeholder, its top and bottom are cropped evenly to fit.
|
| 139 |
+
If it is wider, its left and right sides are cropped evenly. Cropping can be
|
| 140 |
+
adjusted using the crop properties on the placeholder, such as
|
| 141 |
+
:attr:`~.PlaceholderPicture.crop_bottom`.
|
| 142 |
+
|
| 143 |
+
:meth:`.TablePlaceholder.insert_table`
|
| 144 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 145 |
+
|
| 146 |
+
The table placeholder has an :meth:`~.TablePlaceholder.insert_table` method.
|
| 147 |
+
The built-in template has no layout containing a table placeholder, so this
|
| 148 |
+
example assumes a starting presentation named
|
| 149 |
+
``having-table-placeholder.pptx`` having a table placeholder with idx 10 on
|
| 150 |
+
its second slide layout::
|
| 151 |
+
|
| 152 |
+
>>> prs = Presentation('having-table-placeholder.pptx')
|
| 153 |
+
>>> slide = prs.slides.add_slide(prs.slide_layouts[1])
|
| 154 |
+
>>> placeholder = slide.placeholders[10] # idx key, not position
|
| 155 |
+
>>> placeholder.name
|
| 156 |
+
'Table Placeholder 1'
|
| 157 |
+
>>> placeholder.placeholder_format.type
|
| 158 |
+
TABLE (12)
|
| 159 |
+
>>> graphic_frame = placeholder.insert_table(rows=2, cols=2)
|
| 160 |
+
>>> table = graphic_frame.table
|
| 161 |
+
>>> len(table.rows), len(table.columns)
|
| 162 |
+
(2, 2)
|
| 163 |
+
|
| 164 |
+
A table inserted in this way has the position and width of the original
|
| 165 |
+
placeholder. Its height is proportional to the number of rows.
|
| 166 |
+
|
| 167 |
+
Like all rich-content insertion methods, a reference to a table placeholder
|
| 168 |
+
becomes invalid after its :meth:`~.TablePlaceholder.insert_table` method is
|
| 169 |
+
called. This is because the process of inserting rich content replaces the
|
| 170 |
+
original `p:sp` XML element with a new element, a `p:graphicFrame` in this
|
| 171 |
+
case, containing the rich-content object. Any attempt to use the original
|
| 172 |
+
placeholder reference after the call will raise |AttributeError|. The new
|
| 173 |
+
placeholder is the return value of the :meth:`insert_table` call and may also
|
| 174 |
+
be obtained from the placeholders collection using the original `idx` key, 10
|
| 175 |
+
in this case.
|
| 176 |
+
|
| 177 |
+
.. note:: The return value of the :meth:`~.TablePlaceholder.insert_table`
|
| 178 |
+
method is a |PlaceholderGraphicFrame| object, which has all the properties
|
| 179 |
+
and methods of a |GraphicFrame| object along with those specific to
|
| 180 |
+
placeholders. The inserted table is contained in the graphic frame and can
|
| 181 |
+
be obtained using its :attr:`~.PlaceholderGraphicFrame.table` property.
|
| 182 |
+
|
| 183 |
+
:meth:`.ChartPlaceholder.insert_chart`
|
| 184 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 185 |
+
|
| 186 |
+
The chart placeholder has an :meth:`~.ChartPlaceholder.insert_chart` method.
|
| 187 |
+
The presentation template built into |pp| has no layout containing a chart
|
| 188 |
+
placeholder, so this example assumes a starting presentation named
|
| 189 |
+
``having-chart-placeholder.pptx`` having a chart placeholder with idx 10 on
|
| 190 |
+
its second slide layout::
|
| 191 |
+
|
| 192 |
+
>>> from pptx.chart.data import ChartData
|
| 193 |
+
>>> from pptx.enum.chart import XL_CHART_TYPE
|
| 194 |
+
|
| 195 |
+
>>> prs = Presentation('having-chart-placeholder.pptx')
|
| 196 |
+
>>> slide = prs.slides.add_slide(prs.slide_layouts[1])
|
| 197 |
+
|
| 198 |
+
>>> placeholder = slide.placeholders[10] # idx key, not position
|
| 199 |
+
>>> placeholder.name
|
| 200 |
+
'Chart Placeholder 9'
|
| 201 |
+
>>> placeholder.placeholder_format.type
|
| 202 |
+
CHART (12)
|
| 203 |
+
|
| 204 |
+
>>> chart_data = ChartData()
|
| 205 |
+
>>> chart_data.categories = ['Yes', 'No']
|
| 206 |
+
>>> chart_data.add_series('Series 1', (42, 24))
|
| 207 |
+
|
| 208 |
+
>>> graphic_frame = placeholder.insert_chart(XL_CHART_TYPE.PIE, chart_data)
|
| 209 |
+
>>> chart = graphic_frame.chart
|
| 210 |
+
>>> chart.chart_type
|
| 211 |
+
PIE (5)
|
| 212 |
+
|
| 213 |
+
A chart inserted in this way has the position and size of the original
|
| 214 |
+
placeholder.
|
| 215 |
+
|
| 216 |
+
Note the return value from :meth:`~.ChartPlaceholder.insert_chart` is
|
| 217 |
+
a |PlaceholderGraphicFrame| object, not the chart itself.
|
| 218 |
+
A |PlaceholderGraphicFrame| object has all the properties and methods of
|
| 219 |
+
a |GraphicFrame| object along with those specific to placeholders. The
|
| 220 |
+
inserted chart is contained in the graphic frame and can be obtained using
|
| 221 |
+
its :attr:`~.PlaceholderGraphicFrame.chart` property.
|
| 222 |
+
|
| 223 |
+
Like all rich-content insertion methods, a reference to a chart placeholder
|
| 224 |
+
becomes invalid after its :meth:`~.ChartPlaceholder.insert_chart` method is
|
| 225 |
+
called. This is because the process of inserting rich content replaces the
|
| 226 |
+
original `p:sp` XML element with a new element, a `p:graphicFrame` in this
|
| 227 |
+
case, containing the rich-content object. Any attempt to use the original
|
| 228 |
+
placeholder reference after the call will raise |AttributeError|. The new
|
| 229 |
+
placeholder is the return value of the :meth:`insert_chart` call and may also
|
| 230 |
+
be obtained from the placeholders collection using the original `idx` key, 10
|
| 231 |
+
in this case.
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
Setting the slide title
|
| 235 |
+
-----------------------
|
| 236 |
+
|
| 237 |
+
Almost all slide layouts have a title placeholder, which any slide based on
|
| 238 |
+
the layout inherits when the layout is applied. Accessing a slide's title is
|
| 239 |
+
a common operation and there's a dedicated attribute on the shape tree for
|
| 240 |
+
it::
|
| 241 |
+
|
| 242 |
+
title_placeholder = slide.shapes.title
|
| 243 |
+
title_placeholder.text = 'Air-speed Velocity of Unladen Swallows'
|
tasks/tasksmith-74f059424102/tests/source/docs/user/presentations.rst
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Working with Presentations
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
|pp| allows you to create new presentations as well as make changes to
|
| 6 |
+
existing ones. Actually, it only lets you make changes to existing
|
| 7 |
+
presentations; it's just that if you start with a presentation that doesn't
|
| 8 |
+
have any slides, it feels at first like you're creating one from scratch.
|
| 9 |
+
|
| 10 |
+
However, a lot of how a presentation looks is determined by the parts that are
|
| 11 |
+
left when you delete all the slides, specifically the theme, the slide master,
|
| 12 |
+
and the slide layouts that derive from the master. Let's walk through it a step
|
| 13 |
+
at a time using examples, starting with the two things you can do with
|
| 14 |
+
a presentation, open it and save it.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Opening a presentation
|
| 18 |
+
----------------------
|
| 19 |
+
|
| 20 |
+
The simplest way to get started is to open a new presentation without
|
| 21 |
+
specifying a file to open::
|
| 22 |
+
|
| 23 |
+
from pptx import Presentation
|
| 24 |
+
|
| 25 |
+
prs = Presentation()
|
| 26 |
+
prs.save('test.pptx')
|
| 27 |
+
|
| 28 |
+
This creates a new presentation from the built-in default template and saves it
|
| 29 |
+
unchanged to a file named 'test.pptx'. A couple things to note:
|
| 30 |
+
|
| 31 |
+
* The so-called "default template" is actually just a PowerPoint file that
|
| 32 |
+
doesn't have any slides in it, stored with the installed |pp| package. It's
|
| 33 |
+
the same as what you would get if you created a new presentation from a fresh
|
| 34 |
+
PowerPoint install, a 4x3 aspect ratio presentation based on the "White"
|
| 35 |
+
template. Well, except it won't contain any slides. PowerPoint always adds
|
| 36 |
+
a blank first slide by default.
|
| 37 |
+
|
| 38 |
+
* You don't need to do anything to it before you save it. If you want to see
|
| 39 |
+
exactly what that template contains, just look in the 'test.pptx' file this
|
| 40 |
+
creates.
|
| 41 |
+
|
| 42 |
+
* We've called it a *template*, but in fact it's just a regular PowerPoint file
|
| 43 |
+
with all the slides removed. Actual PowerPoint template files (.potx files)
|
| 44 |
+
are something a bit different. More on those later maybe, but you won't need
|
| 45 |
+
them to work with |pp|.
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
REALLY opening a presentation
|
| 49 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 50 |
+
|
| 51 |
+
Okay, so if you want any control at all to speak of over the final
|
| 52 |
+
presentation, or if you want to change an existing presentation, you need to
|
| 53 |
+
open one with a filename::
|
| 54 |
+
|
| 55 |
+
prs = Presentation('existing-prs-file.pptx')
|
| 56 |
+
prs.save('new-file-name.pptx')
|
| 57 |
+
|
| 58 |
+
Things to note:
|
| 59 |
+
|
| 60 |
+
* You can open any PowerPoint 2007 or later file this way (.ppt files from
|
| 61 |
+
PowerPoint 2003 and earlier won't work). While you might not be able to
|
| 62 |
+
manipulate all the contents yet, whatever is already in there will load and
|
| 63 |
+
save just fine. The feature set is still being built out, so you can't add or
|
| 64 |
+
change things like Notes Pages yet, but if the presentation has them |pp| is
|
| 65 |
+
polite enough to leave them alone and smart enough to save them without
|
| 66 |
+
actually understanding what they are.
|
| 67 |
+
|
| 68 |
+
* If you use the same filename to open and save the file, |pp| will obediently
|
| 69 |
+
overwrite the original file without a peep. You'll want to make sure that's
|
| 70 |
+
what you intend.
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
Opening a 'file-like' presentation
|
| 74 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 75 |
+
|
| 76 |
+
|pp| can open a presentation from a so-called *file-like* object. It can also
|
| 77 |
+
save to a file-like object. This can be handy when you want to get the source
|
| 78 |
+
or target presentation over a network connection or from a database and don't
|
| 79 |
+
want to (or aren't allowed to) fuss with interacting with the file system. In
|
| 80 |
+
practice this means you can pass an open file or StringIO/BytesIO stream object
|
| 81 |
+
to open or save a presentation like so::
|
| 82 |
+
|
| 83 |
+
f = open('foobar.pptx')
|
| 84 |
+
prs = Presentation(f)
|
| 85 |
+
f.close()
|
| 86 |
+
|
| 87 |
+
# or
|
| 88 |
+
|
| 89 |
+
with open('foobar.pptx') as f:
|
| 90 |
+
source_stream = StringIO(f.read())
|
| 91 |
+
prs = Presentation(source_stream)
|
| 92 |
+
source_stream.close()
|
| 93 |
+
...
|
| 94 |
+
target_stream = StringIO()
|
| 95 |
+
prs.save(target_stream)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
Okay, so you've got a presentation open and are pretty sure you can save it
|
| 99 |
+
somewhere later. Next step is to get a slide in there ...
|
tasks/tasksmith-74f059424102/tests/source/docs/user/quickstart.rst
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. _examples:
|
| 2 |
+
|
| 3 |
+
Getting Started
|
| 4 |
+
===============
|
| 5 |
+
|
| 6 |
+
A quick way to get started is by trying out some of the examples below to get
|
| 7 |
+
a feel for how to use |pp|.
|
| 8 |
+
|
| 9 |
+
The :ref:`API documentation <api>` can help you with the fine details of
|
| 10 |
+
calling signatures and behaviors.
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
.. highlight:: python
|
| 14 |
+
|
| 15 |
+
----
|
| 16 |
+
|
| 17 |
+
Hello World! example
|
| 18 |
+
--------------------
|
| 19 |
+
|
| 20 |
+
.. image:: /_static/img/hello-world.png
|
| 21 |
+
|
| 22 |
+
|
|
| 23 |
+
|
| 24 |
+
::
|
| 25 |
+
|
| 26 |
+
from pptx import Presentation
|
| 27 |
+
|
| 28 |
+
prs = Presentation()
|
| 29 |
+
title_slide_layout = prs.slide_layouts[0]
|
| 30 |
+
slide = prs.slides.add_slide(title_slide_layout)
|
| 31 |
+
title = slide.shapes.title
|
| 32 |
+
subtitle = slide.placeholders[1]
|
| 33 |
+
|
| 34 |
+
title.text = "Hello, World!"
|
| 35 |
+
subtitle.text = "python-pptx was here!"
|
| 36 |
+
|
| 37 |
+
prs.save('test.pptx')
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
----
|
| 41 |
+
|
| 42 |
+
Bullet slide example
|
| 43 |
+
--------------------
|
| 44 |
+
|
| 45 |
+
.. image:: /_static/img/bullet-slide.png
|
| 46 |
+
|
| 47 |
+
|
|
| 48 |
+
|
| 49 |
+
::
|
| 50 |
+
|
| 51 |
+
from pptx import Presentation
|
| 52 |
+
|
| 53 |
+
prs = Presentation()
|
| 54 |
+
bullet_slide_layout = prs.slide_layouts[1]
|
| 55 |
+
|
| 56 |
+
slide = prs.slides.add_slide(bullet_slide_layout)
|
| 57 |
+
shapes = slide.shapes
|
| 58 |
+
|
| 59 |
+
title_shape = shapes.title
|
| 60 |
+
body_shape = shapes.placeholders[1]
|
| 61 |
+
|
| 62 |
+
title_shape.text = 'Adding a Bullet Slide'
|
| 63 |
+
|
| 64 |
+
tf = body_shape.text_frame
|
| 65 |
+
tf.text = 'Find the bullet slide layout'
|
| 66 |
+
|
| 67 |
+
p = tf.add_paragraph()
|
| 68 |
+
p.text = 'Use _TextFrame.text for first bullet'
|
| 69 |
+
p.level = 1
|
| 70 |
+
|
| 71 |
+
p = tf.add_paragraph()
|
| 72 |
+
p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets'
|
| 73 |
+
p.level = 2
|
| 74 |
+
|
| 75 |
+
prs.save('test.pptx')
|
| 76 |
+
|
| 77 |
+
Not all shapes can contain text, but those that do always have at least one
|
| 78 |
+
paragraph, even if that paragraph is empty and no text is visible within the
|
| 79 |
+
shape. ``_BaseShape.has_text_frame`` can be used to determine whether a shape
|
| 80 |
+
can contain text. (All shapes subclass ``_BaseShape``.) When
|
| 81 |
+
``_BaseShape.has_text_frame`` is ``True``,
|
| 82 |
+
``_BaseShape.text_frame.paragraphs[0]`` returns the first paragraph. The text
|
| 83 |
+
of the first paragraph can be set using ``text_frame.paragraphs[0].text``. As
|
| 84 |
+
a shortcut, the writable properties ``_BaseShape.text`` and
|
| 85 |
+
``_TextFrame.text`` are provided to accomplish the same thing. Note that
|
| 86 |
+
these last two calls delete all the shape's paragraphs except the first one
|
| 87 |
+
before setting the text it contains.
|
| 88 |
+
|
| 89 |
+
----
|
| 90 |
+
|
| 91 |
+
``add_textbox()`` example
|
| 92 |
+
-------------------------
|
| 93 |
+
|
| 94 |
+
.. image:: /_static/img/add-textbox.png
|
| 95 |
+
|
| 96 |
+
|
|
| 97 |
+
|
| 98 |
+
::
|
| 99 |
+
|
| 100 |
+
from pptx import Presentation
|
| 101 |
+
from pptx.util import Inches, Pt
|
| 102 |
+
|
| 103 |
+
prs = Presentation()
|
| 104 |
+
blank_slide_layout = prs.slide_layouts[6]
|
| 105 |
+
slide = prs.slides.add_slide(blank_slide_layout)
|
| 106 |
+
|
| 107 |
+
left = top = width = height = Inches(1)
|
| 108 |
+
txBox = slide.shapes.add_textbox(left, top, width, height)
|
| 109 |
+
tf = txBox.text_frame
|
| 110 |
+
|
| 111 |
+
tf.text = "This is text inside a textbox"
|
| 112 |
+
|
| 113 |
+
p = tf.add_paragraph()
|
| 114 |
+
p.text = "This is a second paragraph that's bold"
|
| 115 |
+
p.font.bold = True
|
| 116 |
+
|
| 117 |
+
p = tf.add_paragraph()
|
| 118 |
+
p.text = "This is a third paragraph that's big"
|
| 119 |
+
p.font.size = Pt(40)
|
| 120 |
+
|
| 121 |
+
prs.save('test.pptx')
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
----
|
| 125 |
+
|
| 126 |
+
``add_picture()`` example
|
| 127 |
+
-------------------------
|
| 128 |
+
|
| 129 |
+
.. image:: /_static/img/add-picture.png
|
| 130 |
+
|
| 131 |
+
|
|
| 132 |
+
|
| 133 |
+
::
|
| 134 |
+
|
| 135 |
+
from pptx import Presentation
|
| 136 |
+
from pptx.util import Inches
|
| 137 |
+
|
| 138 |
+
img_path = 'monty-truth.png'
|
| 139 |
+
|
| 140 |
+
prs = Presentation()
|
| 141 |
+
blank_slide_layout = prs.slide_layouts[6]
|
| 142 |
+
slide = prs.slides.add_slide(blank_slide_layout)
|
| 143 |
+
|
| 144 |
+
left = top = Inches(1)
|
| 145 |
+
pic = slide.shapes.add_picture(img_path, left, top)
|
| 146 |
+
|
| 147 |
+
left = Inches(5)
|
| 148 |
+
height = Inches(5.5)
|
| 149 |
+
pic = slide.shapes.add_picture(img_path, left, top, height=height)
|
| 150 |
+
|
| 151 |
+
prs.save('test.pptx')
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
----
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
``add_shape()`` example
|
| 158 |
+
-------------------------
|
| 159 |
+
|
| 160 |
+
.. image:: /_static/img/add-shape.png
|
| 161 |
+
|
| 162 |
+
|
|
| 163 |
+
|
| 164 |
+
::
|
| 165 |
+
|
| 166 |
+
from pptx import Presentation
|
| 167 |
+
from pptx.enum.shapes import MSO_SHAPE
|
| 168 |
+
from pptx.util import Inches
|
| 169 |
+
|
| 170 |
+
prs = Presentation()
|
| 171 |
+
title_only_slide_layout = prs.slide_layouts[5]
|
| 172 |
+
slide = prs.slides.add_slide(title_only_slide_layout)
|
| 173 |
+
shapes = slide.shapes
|
| 174 |
+
|
| 175 |
+
shapes.title.text = 'Adding an AutoShape'
|
| 176 |
+
|
| 177 |
+
left = Inches(0.93) # 0.93" centers this overall set of shapes
|
| 178 |
+
top = Inches(3.0)
|
| 179 |
+
width = Inches(1.75)
|
| 180 |
+
height = Inches(1.0)
|
| 181 |
+
|
| 182 |
+
shape = shapes.add_shape(MSO_SHAPE.PENTAGON, left, top, width, height)
|
| 183 |
+
shape.text = 'Step 1'
|
| 184 |
+
|
| 185 |
+
left = left + width - Inches(0.4)
|
| 186 |
+
width = Inches(2.0) # chevrons need more width for visual balance
|
| 187 |
+
|
| 188 |
+
for n in range(2, 6):
|
| 189 |
+
shape = shapes.add_shape(MSO_SHAPE.CHEVRON, left, top, width, height)
|
| 190 |
+
shape.text = 'Step %d' % n
|
| 191 |
+
left = left + width - Inches(0.4)
|
| 192 |
+
|
| 193 |
+
prs.save('test.pptx')
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
Constants representing each of the available auto shapes (like
|
| 197 |
+
MSO_SHAPE.ROUNDED_RECT, MSO_SHAPE.CHEVRON, etc.) are listed on the
|
| 198 |
+
:ref:`autoshape-types <MsoAutoShapeType>` page.
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
----
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
``add_table()`` example
|
| 205 |
+
-----------------------
|
| 206 |
+
|
| 207 |
+
.. image:: /_static/img/add-table.png
|
| 208 |
+
|
| 209 |
+
|
|
| 210 |
+
|
| 211 |
+
::
|
| 212 |
+
|
| 213 |
+
from pptx import Presentation
|
| 214 |
+
from pptx.util import Inches
|
| 215 |
+
|
| 216 |
+
prs = Presentation()
|
| 217 |
+
title_only_slide_layout = prs.slide_layouts[5]
|
| 218 |
+
slide = prs.slides.add_slide(title_only_slide_layout)
|
| 219 |
+
shapes = slide.shapes
|
| 220 |
+
|
| 221 |
+
shapes.title.text = 'Adding a Table'
|
| 222 |
+
|
| 223 |
+
rows = cols = 2
|
| 224 |
+
left = top = Inches(2.0)
|
| 225 |
+
width = Inches(6.0)
|
| 226 |
+
height = Inches(0.8)
|
| 227 |
+
|
| 228 |
+
table = shapes.add_table(rows, cols, left, top, width, height).table
|
| 229 |
+
|
| 230 |
+
# set column widths
|
| 231 |
+
table.columns[0].width = Inches(2.0)
|
| 232 |
+
table.columns[1].width = Inches(4.0)
|
| 233 |
+
|
| 234 |
+
# write column headings
|
| 235 |
+
table.cell(0, 0).text = 'Foo'
|
| 236 |
+
table.cell(0, 1).text = 'Bar'
|
| 237 |
+
|
| 238 |
+
# write body cells
|
| 239 |
+
table.cell(1, 0).text = 'Baz'
|
| 240 |
+
table.cell(1, 1).text = 'Qux'
|
| 241 |
+
|
| 242 |
+
prs.save('test.pptx')
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
----
|
| 246 |
+
|
| 247 |
+
Extract all text from slides in presentation
|
| 248 |
+
--------------------------------------------
|
| 249 |
+
|
| 250 |
+
::
|
| 251 |
+
|
| 252 |
+
from pptx import Presentation
|
| 253 |
+
|
| 254 |
+
prs = Presentation(path_to_presentation)
|
| 255 |
+
|
| 256 |
+
# text_runs will be populated with a list of strings,
|
| 257 |
+
# one for each text run in presentation
|
| 258 |
+
text_runs = []
|
| 259 |
+
|
| 260 |
+
for slide in prs.slides:
|
| 261 |
+
for shape in slide.shapes:
|
| 262 |
+
if not shape.has_text_frame:
|
| 263 |
+
continue
|
| 264 |
+
for paragraph in shape.text_frame.paragraphs:
|
| 265 |
+
for run in paragraph.runs:
|
| 266 |
+
text_runs.append(run.text)
|
| 267 |
+
|
tasks/tasksmith-74f059424102/tests/source/docs/user/slides.rst
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Working with Slides
|
| 3 |
+
===================
|
| 4 |
+
|
| 5 |
+
Every slide in a presentation is based on a slide layout. Not surprising then
|
| 6 |
+
that you have to specify which slide layout to use when you create a new slide.
|
| 7 |
+
Let's take a minute to understand a few things about slide layouts that we'll
|
| 8 |
+
need so the slide we add looks the way we want it to.
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
Slide layout basics
|
| 12 |
+
-------------------
|
| 13 |
+
|
| 14 |
+
A slide layout is like a template for a slide. Whatever is on the slide layout
|
| 15 |
+
"shows through" on a slide created with it and formatting choices made on the
|
| 16 |
+
slide layout are inherited by the slide. This is an important feature for
|
| 17 |
+
getting a professional-looking presentation deck, where all the slides are
|
| 18 |
+
formatted consistently. Each slide layout is based on the slide master in
|
| 19 |
+
a similar way, so you can make presentation-wide formatting decisions on the
|
| 20 |
+
slide master and layout-specific decisions on the slide layouts. There can
|
| 21 |
+
actually be multiple slide masters, but I'll pretend for now there's only one.
|
| 22 |
+
Usually there is.
|
| 23 |
+
|
| 24 |
+
The presentation themes that come with PowerPoint have about nine slide
|
| 25 |
+
layouts, with names like *Title*, *Title and Content*, *Title Only*, and
|
| 26 |
+
*Blank*. Each has zero or more placeholders (mostly not zero), preformatted
|
| 27 |
+
areas into which you can place a title, multi-level bullets, an image, etc.
|
| 28 |
+
More on those later.
|
| 29 |
+
|
| 30 |
+
The slide layouts in a standard PowerPoint theme always occur in the same
|
| 31 |
+
sequence. This allows content from one deck to be pasted into another and be
|
| 32 |
+
connected with the right new slide layout:
|
| 33 |
+
|
| 34 |
+
* Title (presentation title slide)
|
| 35 |
+
* Title and Content
|
| 36 |
+
* Section Header (sometimes called Segue)
|
| 37 |
+
* Two Content (side by side bullet textboxes)
|
| 38 |
+
* Comparison (same but additional title for each side by side content box)
|
| 39 |
+
* Title Only
|
| 40 |
+
* Blank
|
| 41 |
+
* Content with Caption
|
| 42 |
+
* Picture with Caption
|
| 43 |
+
|
| 44 |
+
In |pp|, these are ``prs.slide_layouts[0]`` through ``prs.slide_layouts[8]``.
|
| 45 |
+
However, there's no rule they have to appear in this order, it's just
|
| 46 |
+
a convention followed by the themes provided with PowerPoint. If the deck
|
| 47 |
+
you're using as your template has different slide layouts or has them in
|
| 48 |
+
a different order, you'll have to work out the slide layout indices for
|
| 49 |
+
yourself. It's pretty easy. Just open it up in Slide Master view in PowerPoint
|
| 50 |
+
and count down from the top, starting at zero.
|
| 51 |
+
|
| 52 |
+
Now we can get to creating a new slide.
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
Adding a slide
|
| 56 |
+
--------------
|
| 57 |
+
|
| 58 |
+
Let's use the Title and Content slide layout; a lot of slides do::
|
| 59 |
+
|
| 60 |
+
SLD_LAYOUT_TITLE_AND_CONTENT = 1
|
| 61 |
+
|
| 62 |
+
prs = Presentation()
|
| 63 |
+
slide_layout = prs.slide_layouts[SLD_LAYOUT_TITLE_AND_CONTENT]
|
| 64 |
+
slide = prs.slides.add_slide(slide_layout)
|
| 65 |
+
|
| 66 |
+
A few things to note:
|
| 67 |
+
|
| 68 |
+
* Using a "constant" value like ``SLD_LAYOUT_TITLE_AND_CONTENT`` is up to you.
|
| 69 |
+
If you're creating many slides it can be handy to have constants defined so
|
| 70 |
+
a reader can more easily make sense of what you're doing. There isn't a set
|
| 71 |
+
of these built into the package because they can't be assured to be right for
|
| 72 |
+
the starting deck you're using.
|
| 73 |
+
|
| 74 |
+
* ``prs.slide_layouts`` is the collection of slide layouts contained in the
|
| 75 |
+
presentation and has list semantics, at least for item access which is about
|
| 76 |
+
all you can do with that collection at the moment. Using ``prs`` for the
|
| 77 |
+
Presentation instance is purely conventional, but I like it and use it
|
| 78 |
+
consistently.
|
| 79 |
+
|
| 80 |
+
* ``prs.slides`` is the collection of slides in the presentation, also has
|
| 81 |
+
list semantics for item access, and len() works on it. Note that the method
|
| 82 |
+
to add the slide is on the slide collection, not the presentation. The
|
| 83 |
+
``add_slide()`` method appends the new slide to the end of the collection. At
|
| 84 |
+
the time of writing it's the only way to add a slide, but sooner or later
|
| 85 |
+
I expect someone will want to insert one in the middle, and when they post
|
| 86 |
+
a feature request for that I expect I'll add an ``insert_slide(idx, ...)``
|
| 87 |
+
method.
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
Doing other things with slides
|
| 91 |
+
------------------------------
|
| 92 |
+
|
| 93 |
+
Right now, adding a slide is the only operation on the slide collection. On the
|
| 94 |
+
backlog at the time of writing is deleting a slide and moving a slide to
|
| 95 |
+
a different position in the list. Copying a slide from one presentation to
|
| 96 |
+
another turns out to be pretty hard to get right in the general case, so that
|
| 97 |
+
probably won't come until more of the backlog is burned down.
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
Up next ...
|
| 101 |
+
-----------
|
| 102 |
+
|
| 103 |
+
Ok, now that we have a new slide, let's talk about how to put something on
|
| 104 |
+
it ...
|
tasks/tasksmith-74f059424102/tests/source/docs/user/table.rst
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Working with tables
|
| 3 |
+
===================
|
| 4 |
+
|
| 5 |
+
PowerPoint allows text and numbers to be presented in tabular form (aligned
|
| 6 |
+
rows and columns) in a reasonably flexible way. A PowerPoint table is not
|
| 7 |
+
nearly as functional as an Excel spreadsheet, and is definitely less powerful
|
| 8 |
+
than a table in Microsoft Word, but it serves well for most presentation
|
| 9 |
+
purposes.
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Concepts
|
| 13 |
+
--------
|
| 14 |
+
|
| 15 |
+
There are a few terms worth reviewing as a basis for understanding PowerPoint
|
| 16 |
+
tables:
|
| 17 |
+
|
| 18 |
+
table
|
| 19 |
+
A table is a matrix of cells arranged in aligned rows and columns. This
|
| 20 |
+
orderly arrangement allows a reader to more easily make sense of relatively
|
| 21 |
+
large number of individual items. It is commonly used for displaying
|
| 22 |
+
numbers, but can also be used for blocks of text.
|
| 23 |
+
|
| 24 |
+
.. image:: /_static/img/table-01.png
|
| 25 |
+
:scale: 75%
|
| 26 |
+
|
| 27 |
+
cell
|
| 28 |
+
An individual content "container" within a table. A cell has a text-frame
|
| 29 |
+
in which it holds that content. A PowerPoint table cell can only contain
|
| 30 |
+
text. I cannot hold images, other shapes, or other tables.
|
| 31 |
+
|
| 32 |
+
A cell has a background fill, borders, margins, and several other
|
| 33 |
+
formatting settings that can be customized on a cell-by-cell basis.
|
| 34 |
+
|
| 35 |
+
row
|
| 36 |
+
A side-by-side sequence of cells running across the table, all sharing the
|
| 37 |
+
same top and bottom boundary.
|
| 38 |
+
|
| 39 |
+
column
|
| 40 |
+
A vertical sequence of cells spanning the height of the table, all sharing
|
| 41 |
+
the same left and right boundary.
|
| 42 |
+
|
| 43 |
+
table grid, also cell grid
|
| 44 |
+
The underlying cells in a PowerPoint table are strictly regular. In
|
| 45 |
+
a three-by-three table there are nine grid cells, three in each row and
|
| 46 |
+
three in each column. The presence of merged cells can obscure portions of
|
| 47 |
+
the cell grid, but not change the number of cells in the grid. Access to
|
| 48 |
+
a table cell in |pp| is always via that cell's coordinates in the cell
|
| 49 |
+
grid, which may not conform to its visual location (or lack thereof) in the
|
| 50 |
+
table.
|
| 51 |
+
|
| 52 |
+
merged cell
|
| 53 |
+
A cell can be "merged" with adjacent cells, horizontally, vertically, or
|
| 54 |
+
both, causing the resulting cell to look and behave like a single cell that
|
| 55 |
+
spans the area formerly occupied by those individual cells.
|
| 56 |
+
|
| 57 |
+
.. image:: /_static/img/table-02.png
|
| 58 |
+
:scale: 75%
|
| 59 |
+
|
| 60 |
+
merge-origin cell
|
| 61 |
+
The top-left grid-cell in a merged cell has certain special behaviors. The
|
| 62 |
+
content of that cell is what appears on the slide; content of any "spanned"
|
| 63 |
+
cells is hidden. In |pp| a merge-origin cell can be identified with the
|
| 64 |
+
:attr:`._Cell.is_merge_origin` property. Such a cell can report the size of
|
| 65 |
+
the merged cell with its :attr:`.span_height` and :attr:`.span_width`
|
| 66 |
+
properties, and can be "unmerged" back to its underlying grid cells using
|
| 67 |
+
its :meth:`.split` method.
|
| 68 |
+
|
| 69 |
+
spanned-cell
|
| 70 |
+
A grid-cell other than the merge-origin cell that is "occupied" by a merged
|
| 71 |
+
cell is called a *spanned cell*. Intuitively, the merge-origin cell "spans"
|
| 72 |
+
the other grid cells within its area. A spanned cell can be identified with
|
| 73 |
+
its :attr:`._Cell.is_spanned` property. A merge-origin cell is not itself
|
| 74 |
+
a spanned cell.
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
Adding a table
|
| 78 |
+
--------------
|
| 79 |
+
|
| 80 |
+
The following code adds a 3-by-3 table in a new presentation::
|
| 81 |
+
|
| 82 |
+
>>> from pptx import Presentation
|
| 83 |
+
>>> from pptx.util import Inches
|
| 84 |
+
|
| 85 |
+
>>> # ---create presentation with 1 slide---
|
| 86 |
+
>>> prs = Presentation()
|
| 87 |
+
>>> slide = prs.slides.add_slide(prs.slide_layouts[5])
|
| 88 |
+
|
| 89 |
+
>>> # ---add table to slide---
|
| 90 |
+
>>> x, y, cx, cy = Inches(2), Inches(2), Inches(4), Inches(1.5)
|
| 91 |
+
>>> shape = slide.shapes.add_table(3, 3, x, y, cx, cy)
|
| 92 |
+
|
| 93 |
+
>>> shape
|
| 94 |
+
<pptx.shapes.graphfrm.GraphicFrame object at 0x1022816d0>
|
| 95 |
+
>>> shape.has_table
|
| 96 |
+
True
|
| 97 |
+
>>> table = shape.table
|
| 98 |
+
>>> table
|
| 99 |
+
<pptx.table.Table object at 0x1096f8d90>
|
| 100 |
+
|
| 101 |
+
.. image:: /_static/img/table-03.png
|
| 102 |
+
:align: center
|
| 103 |
+
:scale: 60%
|
| 104 |
+
|
| 105 |
+
A couple things to note:
|
| 106 |
+
|
| 107 |
+
* :meth:`.SlideShapes.add_table` returns a shape that contains the table, not
|
| 108 |
+
the table itself. In PowerPoint, a table is contained in a graphic-frame
|
| 109 |
+
shape, as is a chart or SmartArt. You can determine whether a shape
|
| 110 |
+
contains a table using its :attr:`~.BaseShape.has_table` property and you
|
| 111 |
+
access the table object using the shape's :attr:`~.GraphicFrame.table`
|
| 112 |
+
property.
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
Inserting a table into a table placeholder
|
| 116 |
+
------------------------------------------
|
| 117 |
+
|
| 118 |
+
A placeholder allows you to specify the position and size of a shape as part
|
| 119 |
+
of the presentation "template", and to place a shape of your choosing into
|
| 120 |
+
that placeholder when authoring a presentation based on that template. This
|
| 121 |
+
can lead to a better looking presentation, with objects appearing in
|
| 122 |
+
a consistent location from slide-to-slide.
|
| 123 |
+
|
| 124 |
+
Placeholders come in different types, one of which is a *table placeholder*.
|
| 125 |
+
A table placeholder behaves like other placeholders except it can only accept
|
| 126 |
+
insertion of a table. Other placeholder types accept text bullets or charts.
|
| 127 |
+
|
| 128 |
+
There is a subtle distinction between a *layout placeholder* and a *slide
|
| 129 |
+
placeholder*. A layout placeholder appears in a slide layout, and defines the
|
| 130 |
+
position and size of the placeholder "cloned" from it onto each slide created
|
| 131 |
+
with that layout. As long as you don't adjust the position or size of the
|
| 132 |
+
slide placeholder, it will inherit it's position and size from the layout
|
| 133 |
+
placeholder it derives from.
|
| 134 |
+
|
| 135 |
+
To insert a table into a table placeholder, you need a slide layout that
|
| 136 |
+
includes a table placeholder, and you need to create a slide using that
|
| 137 |
+
layout. These examples assume that the third slide layout in `template.pptx`
|
| 138 |
+
includes a table placeholder::
|
| 139 |
+
|
| 140 |
+
>>> prs = Presentation('template.pptx')
|
| 141 |
+
>>> slide = prs.slides.add_slide(prs.slide_layouts[2])
|
| 142 |
+
|
| 143 |
+
*Accessing the table placeholder.* Generally, the easiest way to access
|
| 144 |
+
a placeholder shape is to know its position in the `slide.shapes` collection.
|
| 145 |
+
If you always use the same template, it will always show up in the same
|
| 146 |
+
position::
|
| 147 |
+
|
| 148 |
+
>>> table_placeholder = slide.shapes[1]
|
| 149 |
+
|
| 150 |
+
*Inserting a table.* A table is inserted into the placeholder by calling its
|
| 151 |
+
:meth:`~.TablePlaceholder.insert_table` method and providing the desired
|
| 152 |
+
number of rows and columns::
|
| 153 |
+
|
| 154 |
+
>>> shape = table_placeholder.insert_table(rows=3, cols=4)
|
| 155 |
+
|
| 156 |
+
The return value is a |GraphicFrame| shape containing the new table, not the
|
| 157 |
+
table object itself. Use the :attr:`~.GraphicFrame.table` property of that
|
| 158 |
+
shape to access the table object::
|
| 159 |
+
|
| 160 |
+
>>> table = shape.table
|
| 161 |
+
|
| 162 |
+
The containing shape controls the position and size. Everything else, like
|
| 163 |
+
accessing cells and their contents, is done from the table object.
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
Accessing a cell
|
| 167 |
+
----------------
|
| 168 |
+
|
| 169 |
+
All content in a table is in a cell, so getting a reference to one of those
|
| 170 |
+
is a good place to start::
|
| 171 |
+
|
| 172 |
+
>>> cell = table.cell(0, 0)
|
| 173 |
+
>>> cell.text
|
| 174 |
+
''
|
| 175 |
+
>>> cell.text = 'Unladen Swallow'
|
| 176 |
+
|
| 177 |
+
.. image:: /_static/img/table-04.png
|
| 178 |
+
:align: center
|
| 179 |
+
:scale: 60%
|
| 180 |
+
|
| 181 |
+
The cell is specified by its row, column coordinates as zero-based offsets.
|
| 182 |
+
The top-left cell is at row, column (0, 0).
|
| 183 |
+
|
| 184 |
+
Like an auto-shape, a cell has a text-frame and can contain arbitrary text
|
| 185 |
+
divided into paragraphs and runs. Any desired character formatting can be
|
| 186 |
+
applied individually to each run.
|
| 187 |
+
|
| 188 |
+
Often however, cell text is just a simple string. For these cases the
|
| 189 |
+
read/write :attr:`._Cell.text` property can be the quickest way to set cell
|
| 190 |
+
contents.
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
Merging cells
|
| 194 |
+
-------------
|
| 195 |
+
|
| 196 |
+
A merged cell is produced by specifying two diagonal cells. The merged cell
|
| 197 |
+
will occupy all the grid cells in the rectangular region specified by that
|
| 198 |
+
diagonal:
|
| 199 |
+
|
| 200 |
+
.. image:: /_static/img/table-05.png
|
| 201 |
+
:align: center
|
| 202 |
+
:scale: 60%
|
| 203 |
+
|
| 204 |
+
::
|
| 205 |
+
|
| 206 |
+
>>> cell = table.cell(0, 0)
|
| 207 |
+
>>> other_cell = table.cell(1, 1)
|
| 208 |
+
>>> cell.is_merge_origin
|
| 209 |
+
False
|
| 210 |
+
>>> cell.merge(other_cell)
|
| 211 |
+
>>> cell.is_merge_origin
|
| 212 |
+
True
|
| 213 |
+
>>> cell.is_spanned
|
| 214 |
+
False
|
| 215 |
+
>>> other_cell.is_spanned
|
| 216 |
+
True
|
| 217 |
+
>>> table.cell(0, 1).is_spanned
|
| 218 |
+
True
|
| 219 |
+
|
| 220 |
+
.. image:: /_static/img/table-06.png
|
| 221 |
+
:align: center
|
| 222 |
+
:scale: 60%
|
| 223 |
+
|
| 224 |
+
A few things to observe:
|
| 225 |
+
|
| 226 |
+
* The merged cell appears as a single cell occupying the space formerly
|
| 227 |
+
occupied by the other grid cells in the specified rectangular region.
|
| 228 |
+
|
| 229 |
+
* The formatting of the merged cell (background color, font etc.) is taken
|
| 230 |
+
from the merge origin cell, the top-left cell of the table in this case.
|
| 231 |
+
|
| 232 |
+
* Content from the merged cells was migrated to the merge-origin cell. That
|
| 233 |
+
content is no longer present in the spanned grid cells (although you can't
|
| 234 |
+
see those at the moment). The content of each cell appears as a separate
|
| 235 |
+
paragraph in the merged cell; it isn't concatenated into a single
|
| 236 |
+
paragraph. Content is migrated in left-to-right, top-to-bottom order of the
|
| 237 |
+
original cells.
|
| 238 |
+
|
| 239 |
+
* Calling :attr:`other_cell.merge(cell)` would have the exact same effect. The
|
| 240 |
+
merge origin is always the top-left cell in the specified rectangular
|
| 241 |
+
region. There are four distinct ways to specify a given rectangular region
|
| 242 |
+
(two diagonals, each having two orderings).
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
Un-merging a cell
|
| 246 |
+
-----------------
|
| 247 |
+
|
| 248 |
+
A merged cell can be restored to its underlying grid cells by calling the
|
| 249 |
+
:meth:`~._Cell.split` method on its merge-origin cell. Calling
|
| 250 |
+
:meth:`~._Cell.split()` on a cell that is not a merge-origin raises
|
| 251 |
+
|ValueError|::
|
| 252 |
+
|
| 253 |
+
>>> cell = table.cell(0, 0)
|
| 254 |
+
>>> cell.is_merge_origin
|
| 255 |
+
True
|
| 256 |
+
>>> cell.split()
|
| 257 |
+
>>> cell.is_merge_origin
|
| 258 |
+
False
|
| 259 |
+
>>> table.cell(0, 1).is_spanned
|
| 260 |
+
False
|
| 261 |
+
|
| 262 |
+
.. image:: /_static/img/table-07.png
|
| 263 |
+
:align: center
|
| 264 |
+
:scale: 60%
|
| 265 |
+
|
| 266 |
+
Note that the content migration performed as part of the `.merge()` operation
|
| 267 |
+
was not reversed.
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
A few snippets that might be handy
|
| 271 |
+
----------------------------------
|
| 272 |
+
|
| 273 |
+
Use Case: Interrogate table for merged cells::
|
| 274 |
+
|
| 275 |
+
def iter_merge_origins(table):
|
| 276 |
+
"""Generate each merge-origin cell in *table*.
|
| 277 |
+
|
| 278 |
+
Cell objects are ordered by their position in the table,
|
| 279 |
+
left-to-right, top-to-bottom.
|
| 280 |
+
"""
|
| 281 |
+
return (cell for cell in table.iter_cells() if cell.is_merge_origin)
|
| 282 |
+
|
| 283 |
+
def merged_cell_report(cell):
|
| 284 |
+
"""Return str summarizing position and size of merged *cell*."""
|
| 285 |
+
return (
|
| 286 |
+
'merged cell at row %d, col %d, %d cells high and %d cells wide'
|
| 287 |
+
% (cell.row_idx, cell.col_idx, cell.span_height, cell.span_width)
|
| 288 |
+
)
|
| 289 |
+
|
| 290 |
+
# ---Print a summary line for each merged cell in *table*.---
|
| 291 |
+
for merge_origin_cell in iter_merge_origins(table):
|
| 292 |
+
print(merged_cell_report(merge_origin_cell))
|
| 293 |
+
|
| 294 |
+
prints a report like::
|
| 295 |
+
|
| 296 |
+
merged cell at row 0, col 0, 2 cells high and 2 cells wide
|
| 297 |
+
merged cell at row 3, col 2, 1 cells high and 2 cells wide
|
| 298 |
+
merged cell at row 4, col 0, 2 cells high and 1 cells wide
|
| 299 |
+
|
| 300 |
+
Use Case: Access only cells that display text (are not spanned)::
|
| 301 |
+
|
| 302 |
+
def iter_visible_cells(table):
|
| 303 |
+
return (cell for cell in table.iter_cells() if not cell.is_spanned)
|
| 304 |
+
|
| 305 |
+
Use Case: Determine whether table contains merged cells::
|
| 306 |
+
|
| 307 |
+
def has_merged_cells(table):
|
| 308 |
+
for cell in table.iter_cells():
|
| 309 |
+
if cell.is_merge_origin:
|
| 310 |
+
return True
|
| 311 |
+
return False
|
tasks/tasksmith-74f059424102/tests/source/docs/user/text.rst
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Working with text
|
| 3 |
+
=================
|
| 4 |
+
|
| 5 |
+
Auto shapes and table cells can contain text. Other shapes can't. Text is
|
| 6 |
+
always manipulated the same way, regardless of its container.
|
| 7 |
+
|
| 8 |
+
Text exists in a hierarchy of three levels:
|
| 9 |
+
|
| 10 |
+
* :attr:`.Shape.text_frame`
|
| 11 |
+
* :attr:`.TextFrame.paragraphs`
|
| 12 |
+
* :attr:`._Paragraph.runs`
|
| 13 |
+
|
| 14 |
+
All the text in a shape is contained in its *text frame*. A text frame has
|
| 15 |
+
vertical alignment, margins, wrapping and auto-fit behavior, a rotation angle,
|
| 16 |
+
some possible 3D visual features, and can be set to format its text into
|
| 17 |
+
multiple columns. It also contains a sequence of paragraphs, which always
|
| 18 |
+
contains at least one paragraph, even when empty.
|
| 19 |
+
|
| 20 |
+
A paragraph has line spacing, space before, space after, available bullet
|
| 21 |
+
formatting, tabs, outline/indentation level, and horizontal alignment.
|
| 22 |
+
A paragraph can be empty, but if it contains any text, that text is contained
|
| 23 |
+
in one or more runs.
|
| 24 |
+
|
| 25 |
+
A run exists to provide character level formatting, including font typeface,
|
| 26 |
+
size, and color, an optional hyperlink target URL, bold, italic, and underline
|
| 27 |
+
styles, strikethrough, kerning, and a few capitalization styles like all caps.
|
| 28 |
+
|
| 29 |
+
Let's run through these one by one. Only features available in the current
|
| 30 |
+
release are shown.
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
Accessing the text frame
|
| 34 |
+
------------------------
|
| 35 |
+
|
| 36 |
+
As mentioned, not all shapes have a text frame. So if you're not sure and you
|
| 37 |
+
don't want to catch the possible exception, you'll want to check before
|
| 38 |
+
attempting to access it::
|
| 39 |
+
|
| 40 |
+
for shape in slide.shapes:
|
| 41 |
+
if not shape.has_text_frame:
|
| 42 |
+
continue
|
| 43 |
+
text_frame = shape.text_frame
|
| 44 |
+
# do things with the text frame
|
| 45 |
+
...
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
Accessing paragraphs
|
| 49 |
+
--------------------
|
| 50 |
+
|
| 51 |
+
A text frame always contains at least one paragraph. This causes the process
|
| 52 |
+
of getting multiple paragraphs into a shape to be a little clunkier than one
|
| 53 |
+
might like. Say for example you want a shape with three paragraphs::
|
| 54 |
+
|
| 55 |
+
paragraph_strs = [
|
| 56 |
+
'Egg, bacon, sausage and spam.',
|
| 57 |
+
'Spam, bacon, sausage and spam.',
|
| 58 |
+
'Spam, egg, spam, spam, bacon and spam.'
|
| 59 |
+
]
|
| 60 |
+
|
| 61 |
+
text_frame = shape.text_frame
|
| 62 |
+
text_frame.clear() # remove any existing paragraphs, leaving one empty one
|
| 63 |
+
|
| 64 |
+
p = text_frame.paragraphs[0]
|
| 65 |
+
p.text = paragraph_strs[0]
|
| 66 |
+
|
| 67 |
+
for para_str in paragraph_strs[1:]:
|
| 68 |
+
p = text_frame.add_paragraph()
|
| 69 |
+
p.text = para_str
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
Adding text
|
| 73 |
+
-----------
|
| 74 |
+
|
| 75 |
+
Only runs can actually contain text. Assigning a string to the ``.text``
|
| 76 |
+
attribute on a shape, text frame, or paragraph is a shortcut method for placing
|
| 77 |
+
text in a run contained by those objects. The following two snippets produce
|
| 78 |
+
the same result::
|
| 79 |
+
|
| 80 |
+
shape.text = 'foobar'
|
| 81 |
+
|
| 82 |
+
# is equivalent to ...
|
| 83 |
+
|
| 84 |
+
text_frame = shape.text_frame
|
| 85 |
+
text_frame.clear()
|
| 86 |
+
p = text_frame.paragraphs[0]
|
| 87 |
+
run = p.add_run()
|
| 88 |
+
run.text = 'foobar'
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
Applying text frame-level formatting
|
| 92 |
+
------------------------------------
|
| 93 |
+
|
| 94 |
+
The following produces a shape with a single paragraph, a slightly wider bottom
|
| 95 |
+
than top margin (these default to 0.05"), no left margin, text aligned top, and
|
| 96 |
+
word wrapping turned off. In addition, the auto-size behavior is set to
|
| 97 |
+
adjust the width and height of the shape to fit its text. Note that vertical
|
| 98 |
+
alignment is set on the text frame. Horizontal alignment is set on each
|
| 99 |
+
paragraph::
|
| 100 |
+
|
| 101 |
+
from pptx.util import Inches
|
| 102 |
+
from pptx.enum.text import MSO_ANCHOR, MSO_AUTO_SIZE
|
| 103 |
+
|
| 104 |
+
text_frame = shape.text_frame
|
| 105 |
+
text_frame.text = 'Spam, eggs, and spam'
|
| 106 |
+
text_frame.margin_bottom = Inches(0.08)
|
| 107 |
+
text_frame.margin_left = 0
|
| 108 |
+
text_frame.vertical_anchor = MSO_ANCHOR.TOP
|
| 109 |
+
text_frame.word_wrap = False
|
| 110 |
+
text_frame.auto_size = MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT
|
| 111 |
+
|
| 112 |
+
The possible values for ``TextFrame.auto_size`` and
|
| 113 |
+
``TextFrame.vertical_anchor`` are specified by the enumeration
|
| 114 |
+
:ref:`MsoAutoSize` and :ref:`MsoVerticalAnchor` respectively.
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
Applying paragraph formatting
|
| 118 |
+
-----------------------------
|
| 119 |
+
|
| 120 |
+
The following produces a shape containing three left-aligned paragraphs, the
|
| 121 |
+
second and third indented (like sub-bullets) under the first::
|
| 122 |
+
|
| 123 |
+
from pptx.enum.text import PP_ALIGN
|
| 124 |
+
|
| 125 |
+
paragraph_strs = [
|
| 126 |
+
'Egg, bacon, sausage and spam.',
|
| 127 |
+
'Spam, bacon, sausage and spam.',
|
| 128 |
+
'Spam, egg, spam, spam, bacon and spam.'
|
| 129 |
+
]
|
| 130 |
+
|
| 131 |
+
text_frame = shape.text_frame
|
| 132 |
+
text_frame.clear()
|
| 133 |
+
|
| 134 |
+
p = text_frame.paragraphs[0]
|
| 135 |
+
p.text = paragraph_strs[0]
|
| 136 |
+
p.alignment = PP_ALIGN.LEFT
|
| 137 |
+
|
| 138 |
+
for para_str in paragraph_strs[1:]:
|
| 139 |
+
p = text_frame.add_paragraph()
|
| 140 |
+
p.text = para_str
|
| 141 |
+
p.alignment = PP_ALIGN.LEFT
|
| 142 |
+
p.level = 1
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
Applying character formatting
|
| 146 |
+
-----------------------------
|
| 147 |
+
|
| 148 |
+
Character level formatting is applied at the run level, using the ``.font``
|
| 149 |
+
attribute. The following formats a sentence in 18pt Calibri Bold and applies
|
| 150 |
+
the theme color Accent 1.
|
| 151 |
+
|
| 152 |
+
::
|
| 153 |
+
|
| 154 |
+
from pptx.dml.color import RGBColor
|
| 155 |
+
from pptx.enum.dml import MSO_THEME_COLOR
|
| 156 |
+
from pptx.util import Pt
|
| 157 |
+
|
| 158 |
+
text_frame = shape.text_frame
|
| 159 |
+
text_frame.clear() # not necessary for newly-created shape
|
| 160 |
+
|
| 161 |
+
p = text_frame.paragraphs[0]
|
| 162 |
+
run = p.add_run()
|
| 163 |
+
run.text = 'Spam, eggs, and spam'
|
| 164 |
+
|
| 165 |
+
font = run.font
|
| 166 |
+
font.name = 'Calibri'
|
| 167 |
+
font.size = Pt(18)
|
| 168 |
+
font.bold = True
|
| 169 |
+
font.italic = None # cause value to be inherited from theme
|
| 170 |
+
font.color.theme_color = MSO_THEME_COLOR.ACCENT_1
|
| 171 |
+
|
| 172 |
+
If you prefer, you can set the font color to an absolute RGB value. Note that
|
| 173 |
+
this will not change color when the theme is changed::
|
| 174 |
+
|
| 175 |
+
font.color.rgb = RGBColor(0xFF, 0x7F, 0x50)
|
| 176 |
+
|
| 177 |
+
A run can also be made into a hyperlink by providing a target URL::
|
| 178 |
+
|
| 179 |
+
run.hyperlink.address = 'https://github.com/scanny/python-pptx'
|
tasks/tasksmith-74f059424102/tests/source/docs/user/understanding-shapes.rst
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Understanding Shapes
|
| 3 |
+
====================
|
| 4 |
+
|
| 5 |
+
Pretty much anything on a slide is a shape; the only thing I can think of that
|
| 6 |
+
can appear on a slide that's not a shape is a slide background. There are
|
| 7 |
+
between six and ten different types of shape, depending how you count. I'll
|
| 8 |
+
explain some of the general shape concepts you'll need to make sense of how to
|
| 9 |
+
work with them and then we'll jump right into working with the specific types.
|
| 10 |
+
|
| 11 |
+
Technically there are six and only six different types of shapes that can be
|
| 12 |
+
placed on a slide:
|
| 13 |
+
|
| 14 |
+
auto shape
|
| 15 |
+
This is a regular shape, like a rectangle, an ellipse, or a block arrow.
|
| 16 |
+
They come in a large variety of preset shapes, in the neighborhood of 180
|
| 17 |
+
different ones. An auto shape can have a fill and an outline, and can
|
| 18 |
+
contain text. Some auto shapes have adjustments, the little yellow diamonds
|
| 19 |
+
you can drag to adjust how round the corners of a rounded rectangle are for
|
| 20 |
+
example. A text box is also an autoshape, a rectangular one, just by default
|
| 21 |
+
without a fill and without an outline.
|
| 22 |
+
|
| 23 |
+
picture
|
| 24 |
+
A raster image, like a photograph or clip art is referred to as a *picture*
|
| 25 |
+
in PowerPoint. It's its own kind of shape with different behaviors than an
|
| 26 |
+
autoshape. Note that an auto shape can have a picture fill, in which an
|
| 27 |
+
image "shows through" as the background of the shape instead of a fill color
|
| 28 |
+
or gradient. That's a different thing. But cool.
|
| 29 |
+
|
| 30 |
+
graphic frame
|
| 31 |
+
This is the technical name for the container that holds a table, a chart,
|
| 32 |
+
a smart art diagram, or media clip. You can't add one of these by itself,
|
| 33 |
+
it just shows up in the file when you add a graphical object. You probably
|
| 34 |
+
won't need to know anything more about these.
|
| 35 |
+
|
| 36 |
+
group shape
|
| 37 |
+
In PowerPoint, a set of shapes can be *grouped*, allowing them to be
|
| 38 |
+
selected, moved, resized, and even filled as a unit. When you group a set of
|
| 39 |
+
shapes a group shape gets created to contain those member shapes. You can't
|
| 40 |
+
actually see these except by their bounding box when the group is
|
| 41 |
+
selected.
|
| 42 |
+
|
| 43 |
+
line/connector
|
| 44 |
+
Lines are different from auto shapes because, well, they're linear. Some
|
| 45 |
+
lines can be connected to other shapes and stay connected when the other
|
| 46 |
+
shape is moved. These aren't supported yet either so I don't know much more
|
| 47 |
+
about them. I'd better get to these soon though, they seem like they'd be
|
| 48 |
+
very handy.
|
| 49 |
+
|
| 50 |
+
content part
|
| 51 |
+
I actually have only the vaguest notion of what these are. It has something
|
| 52 |
+
to do with embedding "foreign" XML like SVG in with the presentation. I'm
|
| 53 |
+
pretty sure PowerPoint itself doesn't do anything with these. My strategy
|
| 54 |
+
is to ignore them. Working good so far.
|
| 55 |
+
|
| 56 |
+
As for real-life shapes, there are these nine types:
|
| 57 |
+
|
| 58 |
+
* shape shapes -- auto shapes with fill and an outline
|
| 59 |
+
* text boxes -- auto shapes with no fill and no outline
|
| 60 |
+
* placeholders -- auto shapes that can appear on a slide layout or master and
|
| 61 |
+
be inherited on slides that use that layout, allowing content to be added
|
| 62 |
+
that takes on the formatting of the placeholder
|
| 63 |
+
* line/connector -- as described above
|
| 64 |
+
* picture -- as described above
|
| 65 |
+
* table -- that row and column thing
|
| 66 |
+
* chart -- pie chart, line chart, etc.
|
| 67 |
+
* smart art -- not supported yet, although preserved if present
|
| 68 |
+
* media clip -- video or audio
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
Accessing the shapes on a slide
|
| 72 |
+
-------------------------------
|
| 73 |
+
|
| 74 |
+
Each slide has a *shape tree* that holds its shapes. It's called a tree because
|
| 75 |
+
it's hierarchical in the general case; a node in the shape tree can be a group
|
| 76 |
+
shape which itself can contain shapes and has the same semantics as the shape
|
| 77 |
+
tree. For most purposes the shape tree has list semantics. You gain access to
|
| 78 |
+
it like so::
|
| 79 |
+
|
| 80 |
+
shapes = slide.shapes
|
| 81 |
+
|
| 82 |
+
We'll see a lot more of the shape tree in the next few sections.
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
Up next ...
|
| 86 |
+
-----------
|
| 87 |
+
|
| 88 |
+
Okay. That should be enough noodle work to get started. Let's move on to
|
| 89 |
+
working with AutoShapes.
|
tasks/tasksmith-74f059424102/tests/source/docs/user/use-cases.rst
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Use cases
|
| 2 |
+
=========
|
| 3 |
+
|
| 4 |
+
The use case that drove me to begin work on this library has been to automate
|
| 5 |
+
the building of slides that are tedious to compose by hand. As an example,
|
| 6 |
+
consider the task of composing a slide with an array of 10 headshot images of
|
| 7 |
+
folks in a particular department, with the person's name and title next to
|
| 8 |
+
their picture. After doing this a dozen times and struggling to get all the
|
| 9 |
+
alignment and sizes to the point where my attention to detail is satisfied,
|
| 10 |
+
well, my coding fingers got quite itchy.
|
| 11 |
+
|
| 12 |
+
However I believe a broader application will be server-side document
|
| 13 |
+
generation on non-Windows server platforms, Linux primarily I expect. In my
|
| 14 |
+
organization, I have found an apparently insatiable demand for PowerPoint
|
| 15 |
+
documents as a means of communication. Once one rises beyond the level of
|
| 16 |
+
project manager it seems the willingness to interpret text longer than a
|
| 17 |
+
bullet point atrophies quite rapidly and PowerPoint becomes an everyday
|
| 18 |
+
medium. I've imagined it might be pretty cool to be able to generate a
|
| 19 |
+
"presentation-ready" deck for a salesperson that includes a particular subset
|
| 20 |
+
of the product catalog they could generate with a few clicks to use in a sales
|
| 21 |
+
presentation, for example. As you come up with applications I'd love to hear
|
| 22 |
+
about them.
|
tasks/tasksmith-74f059424102/tests/source/features/act-action.feature
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Get and set click action properties
|
| 2 |
+
In order to determine the click action of a shape or text run
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need a set of properties on ActionSetting
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: Get ActionSetting.action
|
| 8 |
+
Given a shape having click action <action>
|
| 9 |
+
Then click_action.action is <value>
|
| 10 |
+
|
| 11 |
+
Examples: Click actions
|
| 12 |
+
| action | value |
|
| 13 |
+
| none | NONE |
|
| 14 |
+
| first slide | FIRST_SLIDE |
|
| 15 |
+
| last slide | LAST_SLIDE |
|
| 16 |
+
| previous slide | PREVIOUS_SLIDE |
|
| 17 |
+
| next slide | NEXT_SLIDE |
|
| 18 |
+
| last slide viewed | LAST_SLIDE_VIEWED |
|
| 19 |
+
| named slide | NAMED_SLIDE |
|
| 20 |
+
| end show | END_SHOW |
|
| 21 |
+
| hyperlink | HYPERLINK |
|
| 22 |
+
| other presentation | PLAY |
|
| 23 |
+
| open file | OPEN_FILE |
|
| 24 |
+
| custom slide show | NAMED_SLIDE_SHOW |
|
| 25 |
+
| OLE action | OLE_VERB |
|
| 26 |
+
| run macro | RUN_MACRO |
|
| 27 |
+
| run program | RUN_PROGRAM |
|
| 28 |
+
| play media | NONE |
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
Scenario Outline: Get ActionSetting.hyperlink
|
| 32 |
+
Given a shape having click action <action>
|
| 33 |
+
Then click_action.hyperlink is a Hyperlink object
|
| 34 |
+
|
| 35 |
+
Examples: Click actions
|
| 36 |
+
| action |
|
| 37 |
+
| none |
|
| 38 |
+
| first slide |
|
| 39 |
+
| last slide |
|
| 40 |
+
| previous slide |
|
| 41 |
+
| next slide |
|
| 42 |
+
| last slide viewed |
|
| 43 |
+
| named slide |
|
| 44 |
+
| end show |
|
| 45 |
+
| hyperlink |
|
| 46 |
+
| other presentation |
|
| 47 |
+
| open file |
|
| 48 |
+
| custom slide show |
|
| 49 |
+
| OLE action |
|
| 50 |
+
| run macro |
|
| 51 |
+
| run program |
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
Scenario Outline: Get ActionSetting.target_slide
|
| 55 |
+
Given a shape having click action <action>
|
| 56 |
+
Then click_action.target_slide is <value>
|
| 57 |
+
|
| 58 |
+
Examples: Click actions
|
| 59 |
+
| action | value |
|
| 60 |
+
| none | None |
|
| 61 |
+
| first slide | slides[0] |
|
| 62 |
+
| last slide | slides[4] |
|
| 63 |
+
| previous slide | slides[1] |
|
| 64 |
+
| next slide | slides[3] |
|
| 65 |
+
| last slide viewed | None |
|
| 66 |
+
| named slide | slides[2] |
|
| 67 |
+
| end show | None |
|
| 68 |
+
| hyperlink | None |
|
| 69 |
+
| other presentation | None |
|
| 70 |
+
| open file | None |
|
| 71 |
+
| custom slide show | None |
|
| 72 |
+
| OLE action | None |
|
| 73 |
+
| run macro | None |
|
| 74 |
+
| run program | None |
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
Scenario Outline: Set ActionSetting.target_slide
|
| 78 |
+
Given an ActionSetting object having action <action> as click_action
|
| 79 |
+
And another slide in the deck as slide
|
| 80 |
+
When I assign <rhs> to click_action.target_slide
|
| 81 |
+
Then click_action.action is <member>
|
| 82 |
+
And click_action.target_slide is <value>
|
| 83 |
+
|
| 84 |
+
Examples: Click actions
|
| 85 |
+
| action | rhs | member | value |
|
| 86 |
+
| NONE | slide | NAMED_SLIDE | slide |
|
| 87 |
+
| NAMED_SLIDE | slide | NAMED_SLIDE | slide |
|
| 88 |
+
| NAMED_SLIDE | None | NONE | None |
|
tasks/tasksmith-74f059424102/tests/source/features/act-hyperlink.feature
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Get or set an external hyperlink on a shape or text run
|
| 2 |
+
In order to connect a presentation to external resources
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need CRUD operations on the Hyperlink object
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: Get hyperlink URL
|
| 8 |
+
Given a shape having click action <action>
|
| 9 |
+
Then click_action.hyperlink.address is <value>
|
| 10 |
+
|
| 11 |
+
Examples: Click actions
|
| 12 |
+
| action | value |
|
| 13 |
+
| none | None |
|
| 14 |
+
| first slide | None |
|
| 15 |
+
| last slide viewed | None |
|
| 16 |
+
| named slide | slide3.xml |
|
| 17 |
+
| hyperlink | http://yahoo.com |
|
| 18 |
+
| custom slide show | None |
|
| 19 |
+
| OLE action | None |
|
| 20 |
+
| run macro | None |
|
| 21 |
+
| run program | file:////Applications/Calculator.app |
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
Scenario Outline: Add hyperlink
|
| 25 |
+
Given a shape having click action <action>
|
| 26 |
+
When I assign <value> to click_action.hyperlink.address
|
| 27 |
+
Then click_action.hyperlink.address is <value>
|
| 28 |
+
|
| 29 |
+
Examples: Click actions
|
| 30 |
+
| action | value |
|
| 31 |
+
| none | http://foobar.com |
|
| 32 |
+
| first slide | http://barfoo.com |
|
| 33 |
+
| named slide | http://barbaz.org |
|
| 34 |
+
| hyperlink | http://hooya.com |
|
| 35 |
+
| run program | http://booya.com |
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
Scenario Outline: Remove hyperlink
|
| 39 |
+
Given a shape having click action <action>
|
| 40 |
+
When I assign None to click_action.hyperlink.address
|
| 41 |
+
Then click_action.hyperlink.address is None
|
| 42 |
+
|
| 43 |
+
Examples: Click actions
|
| 44 |
+
| action |
|
| 45 |
+
| none |
|
| 46 |
+
| first slide |
|
| 47 |
+
| last slide viewed |
|
| 48 |
+
| named slide |
|
| 49 |
+
| hyperlink |
|
| 50 |
+
| custom slide show |
|
| 51 |
+
| OLE action |
|
| 52 |
+
| run macro |
|
| 53 |
+
| run program |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-axis-props.feature
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Axis properties
|
| 2 |
+
In order to customize the formatting of an axis on a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need read/write properties on Axis
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: Get Axis.axis_title
|
| 8 |
+
Given an axis
|
| 9 |
+
Then axis.axis_title is an AxisTitle object
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Scenario Outline: Get Axis.category_type
|
| 13 |
+
Given an axis of type <axis-type>
|
| 14 |
+
Then axis.category_type is XL_CATEGORY_TYPE.<member>
|
| 15 |
+
|
| 16 |
+
Examples: axis category type cases
|
| 17 |
+
| axis-type | member |
|
| 18 |
+
| CategoryAxis | CATEGORY_SCALE |
|
| 19 |
+
| DateAxis | TIME_SCALE |
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
Scenario Outline: Get value_axis.crosses
|
| 23 |
+
Given a value axis having category axis crossing of <crossing>
|
| 24 |
+
Then value_axis.crosses is <member>
|
| 25 |
+
|
| 26 |
+
Examples: value_axis.crosses cases
|
| 27 |
+
| crossing | member |
|
| 28 |
+
| automatic | AUTOMATIC |
|
| 29 |
+
| maximum | MAXIMUM |
|
| 30 |
+
| minimum | MINIMUM |
|
| 31 |
+
| 2.75 | CUSTOM |
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
Scenario Outline: Set value_axis.crosses
|
| 35 |
+
Given a value axis having category axis crossing of <crossing>
|
| 36 |
+
When I assign <member> to value_axis.crosses
|
| 37 |
+
Then value_axis.crosses is <member>
|
| 38 |
+
|
| 39 |
+
Examples: value_axis.crosses assignment cases
|
| 40 |
+
| crossing | member |
|
| 41 |
+
| automatic | MAXIMUM |
|
| 42 |
+
| maximum | MINIMUM |
|
| 43 |
+
| minimum | CUSTOM |
|
| 44 |
+
| 2.75 | CUSTOM |
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
Scenario Outline: Get value_axis.crosses_at
|
| 48 |
+
Given a value axis having category axis crossing of <crossing>
|
| 49 |
+
Then value_axis.crosses_at is <value>
|
| 50 |
+
|
| 51 |
+
Examples: value_axis.crosses_at cases
|
| 52 |
+
| crossing | value |
|
| 53 |
+
| automatic | None |
|
| 54 |
+
| maximum | None |
|
| 55 |
+
| minimum | None |
|
| 56 |
+
| 2.75 | 2.75 |
|
| 57 |
+
| -1.5 | -1.5 |
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
Scenario Outline: Set value_axis.crosses_at
|
| 61 |
+
Given a value axis having category axis crossing of <crossing>
|
| 62 |
+
When I assign <value> to value_axis.crosses_at
|
| 63 |
+
Then value_axis.crosses_at is <value>
|
| 64 |
+
|
| 65 |
+
Examples: value_axis.crosses_at assignment cases
|
| 66 |
+
| crossing | value |
|
| 67 |
+
| automatic | 2.75 |
|
| 68 |
+
| 2.75 | -1.5 |
|
| 69 |
+
| -1.5 | None |
|
| 70 |
+
| automatic | None |
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
Scenario Outline: Get Axis.format
|
| 74 |
+
Given a <axis-type> axis
|
| 75 |
+
Then axis.format is a ChartFormat object
|
| 76 |
+
And axis.format.fill is a FillFormat object
|
| 77 |
+
And axis.format.line is a LineFormat object
|
| 78 |
+
|
| 79 |
+
Examples: axis types
|
| 80 |
+
| axis-type |
|
| 81 |
+
| category |
|
| 82 |
+
| value |
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
Scenario Outline: Get Axis.has_[major/minor]_gridlines
|
| 86 |
+
Given an axis <having-or-not> <major-or-minor> gridlines
|
| 87 |
+
Then axis.has_<major-or-minor>_gridlines is <expected-value>
|
| 88 |
+
|
| 89 |
+
Examples: gridlines presence cases
|
| 90 |
+
| having-or-not | major-or-minor | expected-value |
|
| 91 |
+
| having | major | True |
|
| 92 |
+
| not having | major | False |
|
| 93 |
+
| having | minor | True |
|
| 94 |
+
| not having | minor | False |
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
Scenario Outline: Set Axis.has_[major/minor]_gridlines
|
| 98 |
+
Given an axis <having-or-not> <major-or-minor> gridlines
|
| 99 |
+
When I assign <value> to axis.has_<major-or-minor>_gridlines
|
| 100 |
+
Then axis.has_<major-or-minor>_gridlines is <expected-value>
|
| 101 |
+
|
| 102 |
+
Examples: has_major/minor_gridlines assignment cases
|
| 103 |
+
| having-or-not | major-or-minor | value | expected-value |
|
| 104 |
+
| having | major | False | False |
|
| 105 |
+
| having | major | True | True |
|
| 106 |
+
| not having | minor | False | False |
|
| 107 |
+
| not having | minor | True | True |
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
Scenario Outline: Get Axis.has_title
|
| 111 |
+
Given an axis having <a-or-no> title
|
| 112 |
+
Then axis.has_title is <expected-value>
|
| 113 |
+
|
| 114 |
+
Examples: axis title presence cases
|
| 115 |
+
| a-or-no | expected-value |
|
| 116 |
+
| a | True |
|
| 117 |
+
| no | False |
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
Scenario Outline: Set Axis.has_title
|
| 121 |
+
Given an axis having <a-or-no> title
|
| 122 |
+
When I assign <value> to axis.has_title
|
| 123 |
+
Then axis.has_title is <expected-value>
|
| 124 |
+
|
| 125 |
+
Examples: axis title assignment cases
|
| 126 |
+
| a-or-no | value | expected-value |
|
| 127 |
+
| a | True | True |
|
| 128 |
+
| a | False | False |
|
| 129 |
+
| no | True | True |
|
| 130 |
+
| no | False | False |
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
Scenario Outline: Get Axis.major/minor_unit
|
| 134 |
+
Given an axis having <major-or-minor> unit of <value>
|
| 135 |
+
Then axis.<major-or-minor>_unit is <expected-value>
|
| 136 |
+
|
| 137 |
+
Examples: axis unit cases
|
| 138 |
+
| major-or-minor | value | expected-value |
|
| 139 |
+
| major | 20.0 | 20.0 |
|
| 140 |
+
| major | Auto | None |
|
| 141 |
+
| minor | 4.2 | 4.2 |
|
| 142 |
+
| minor | Auto | None |
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
Scenario Outline: Set Axis.major/minor_unit
|
| 146 |
+
Given an axis having <major-or-minor> unit of <value>
|
| 147 |
+
When I assign <new-value> to axis.<major-or-minor>_unit
|
| 148 |
+
Then axis.<major-or-minor>_unit is <expected-value>
|
| 149 |
+
|
| 150 |
+
Examples: major/minor_unit assignment cases
|
| 151 |
+
| major-or-minor | value | new-value | expected-value |
|
| 152 |
+
| major | 20.0 | 5 | 5.0 |
|
| 153 |
+
| major | 20.0 | None | None |
|
| 154 |
+
| major | Auto | 5 | 5.0 |
|
| 155 |
+
| major | Auto | None | None |
|
| 156 |
+
| minor | 4.2 | 8.4 | 8.4 |
|
| 157 |
+
| minor | 4.2 | None | None |
|
| 158 |
+
| minor | Auto | 8.4 | 8.4 |
|
| 159 |
+
| minor | Auto | None | None |
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
Scenario: Get Axis.major_gridlines
|
| 163 |
+
Given an axis
|
| 164 |
+
Then axis.major_gridlines is a MajorGridlines object
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
Scenario Outline: Get Axis.reverse_order
|
| 168 |
+
Given an axis having reverse-order turned <status>
|
| 169 |
+
Then axis.reverse_order is <expected-value>
|
| 170 |
+
|
| 171 |
+
Examples: axis unit cases
|
| 172 |
+
| status | expected-value |
|
| 173 |
+
| on | True |
|
| 174 |
+
| off | False |
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
Scenario Outline: Set Axis.reverse_order
|
| 178 |
+
Given an axis having reverse-order turned <status>
|
| 179 |
+
When I assign <value> to axis.reverse_order
|
| 180 |
+
Then axis.reverse_order is <expected-value>
|
| 181 |
+
|
| 182 |
+
Examples: major/minor_unit assignment cases
|
| 183 |
+
| status | value | expected-value |
|
| 184 |
+
| off | False | False |
|
| 185 |
+
| off | True | True |
|
| 186 |
+
| on | False | False |
|
| 187 |
+
| on | True | True |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-axistitle-props.feature
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Axis Title properties
|
| 2 |
+
In order to customize the formatting of an axis title
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need read/write properties on AxisTitle
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: AxisTitle.format
|
| 8 |
+
Given an axis title
|
| 9 |
+
Then axis_title.format is a ChartFormat object
|
| 10 |
+
And axis_title.format.fill is a FillFormat object
|
| 11 |
+
And axis_title.format.line is a LineFormat object
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Scenario Outline: Get AxisTitle.has_text_frame
|
| 15 |
+
Given an axis title having <a-or-no> text frame
|
| 16 |
+
Then axis_title.has_text_frame is <value>
|
| 17 |
+
|
| 18 |
+
Examples: text frame presence cases
|
| 19 |
+
| a-or-no | value |
|
| 20 |
+
| a | True |
|
| 21 |
+
| no | False |
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
Scenario Outline: Set AxisTitle.has_text_frame
|
| 25 |
+
Given an axis title having <a-or-no> text frame
|
| 26 |
+
When I assign <new-value> to axis_title.has_text_frame
|
| 27 |
+
Then axis_title.has_text_frame is <value>
|
| 28 |
+
|
| 29 |
+
Examples: axis_title.has_text_frame assignment cases
|
| 30 |
+
| a-or-no | new-value | value |
|
| 31 |
+
| no | True | True |
|
| 32 |
+
| a | False | False |
|
| 33 |
+
| no | False | False |
|
| 34 |
+
| a | True | True |
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
Scenario Outline: Get AxisTitle.text_frame
|
| 38 |
+
Given an axis title having <a-or-no> text frame
|
| 39 |
+
Then axis_title.text_frame is a TextFrame object
|
| 40 |
+
|
| 41 |
+
Examples: text frame presence cases
|
| 42 |
+
| a-or-no |
|
| 43 |
+
| a |
|
| 44 |
+
| no |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-category-access.feature
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Access a category
|
| 2 |
+
In order to operate on an individual category
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need sequence operations on the Categories object
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: Categories.__len__()
|
| 8 |
+
Given a Categories object containing 3 categories
|
| 9 |
+
Then len(categories) is 3
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Scenario: Categories.__getitem__()
|
| 13 |
+
Given a Categories object containing 3 categories
|
| 14 |
+
Then categories[2] is a Category object
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Scenario: Categories.__iter__()
|
| 18 |
+
Given a Categories object containing 3 categories
|
| 19 |
+
Then iterating categories produces 3 Category objects
|
| 20 |
+
And list(categories) == ['Foo', '', 'Baz']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
Scenario Outline: Categories.depth
|
| 24 |
+
Given a Categories object having <depth> category levels
|
| 25 |
+
Then categories.depth is <depth>
|
| 26 |
+
|
| 27 |
+
Examples: hierarchical category depths
|
| 28 |
+
| depth |
|
| 29 |
+
| 0 |
|
| 30 |
+
| 1 |
|
| 31 |
+
| 2 |
|
| 32 |
+
| 3 |
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
Scenario Outline: Categories.levels
|
| 36 |
+
Given a Categories object having <depth> category levels
|
| 37 |
+
Then categories.levels contains <len> CategoryLevel objects
|
| 38 |
+
|
| 39 |
+
Examples: hierarchical category depths
|
| 40 |
+
| depth | len |
|
| 41 |
+
| 0 | 0 |
|
| 42 |
+
| 1 | 0 |
|
| 43 |
+
| 2 | 2 |
|
| 44 |
+
| 3 | 3 |
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
Scenario Outline: Categories.flattened_labels
|
| 48 |
+
Given a Categories object having <leafs> categories and <levels> levels
|
| 49 |
+
Then categories.flattened_labels is a tuple of <leafs> tuples
|
| 50 |
+
And each label tuple contains <levels> labels
|
| 51 |
+
|
| 52 |
+
Examples: hierarchical category combinations
|
| 53 |
+
| leafs | levels |
|
| 54 |
+
| 3 | 1 |
|
| 55 |
+
| 8 | 3 |
|
| 56 |
+
| 0 | 0 |
|
| 57 |
+
| 4 | 2 |
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
Scenario: CategoryLevel.__len__()
|
| 61 |
+
Given a CategoryLevel object containing 4 categories
|
| 62 |
+
Then len(category_level) is 4
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
Scenario: CategoryLevel.__getitem__()
|
| 66 |
+
Given a CategoryLevel object containing 4 categories
|
| 67 |
+
Then category_level[2] is a Category object
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
Scenario: CategoryLevel.__iter__()
|
| 71 |
+
Given a CategoryLevel object containing 4 categories
|
| 72 |
+
Then iterating category_level produces 4 Category objects
|
tasks/tasksmith-74f059424102/tests/source/features/cht-category-props.feature
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Category properties
|
| 2 |
+
In order to characterize a chart category
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need properties on the Category object
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: Category.idx
|
| 8 |
+
Given a Category object having idx value <idx>
|
| 9 |
+
Then category.idx is <idx>
|
| 10 |
+
|
| 11 |
+
Examples: idx cases
|
| 12 |
+
| idx |
|
| 13 |
+
| 1 |
|
| 14 |
+
| 2 |
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Scenario Outline: Category.label
|
| 18 |
+
Given a Category object having <label>
|
| 19 |
+
Then category.label is <value>
|
| 20 |
+
|
| 21 |
+
Examples: label cases
|
| 22 |
+
| label | value |
|
| 23 |
+
| label 'Foo' | 'Foo' |
|
| 24 |
+
| no label | '' |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-chart.feature
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Chart properties
|
| 2 |
+
In order to customize the formatting of a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need read/write properties and methods on Chart
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: Chart.chart_title
|
| 8 |
+
Given a chart having <a-or-no> title
|
| 9 |
+
Then chart.chart_title is a ChartTitle object
|
| 10 |
+
|
| 11 |
+
Examples: chart title presence cases
|
| 12 |
+
| a-or-no |
|
| 13 |
+
| a |
|
| 14 |
+
| no |
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Scenario Outline: Get Chart.chart_type
|
| 18 |
+
Given a chart of type <chart-type>
|
| 19 |
+
Then chart.chart_type is <expected-enum-member>
|
| 20 |
+
|
| 21 |
+
Examples: chart types
|
| 22 |
+
| chart-type | expected-enum-member |
|
| 23 |
+
| Area | AREA |
|
| 24 |
+
| Stacked Area | AREA_STACKED |
|
| 25 |
+
| 100% Stacked Area | AREA_STACKED_100 |
|
| 26 |
+
| 3-D Area | THREE_D_AREA |
|
| 27 |
+
| 3-D Stacked Area | THREE_D_AREA_STACKED |
|
| 28 |
+
| 3-D 100% Stacked Area | THREE_D_AREA_STACKED_100 |
|
| 29 |
+
| Clustered Bar | BAR_CLUSTERED |
|
| 30 |
+
| Stacked Bar | BAR_STACKED |
|
| 31 |
+
| 100% Stacked Bar | BAR_STACKED_100 |
|
| 32 |
+
| Clustered Column | COLUMN_CLUSTERED |
|
| 33 |
+
| Stacked Column | COLUMN_STACKED |
|
| 34 |
+
| 100% Stacked Column | COLUMN_STACKED_100 |
|
| 35 |
+
| Line | LINE |
|
| 36 |
+
| Stacked Line | LINE_STACKED |
|
| 37 |
+
| 100% Stacked Line | LINE_STACKED_100 |
|
| 38 |
+
| Marked Line | LINE_MARKERS |
|
| 39 |
+
| Stacked Marked Line | LINE_MARKERS_STACKED |
|
| 40 |
+
| 100% Stacked Marked Line | LINE_MARKERS_STACKED_100 |
|
| 41 |
+
| Pie | PIE |
|
| 42 |
+
| Exploded Pie | PIE_EXPLODED |
|
| 43 |
+
| XY (Scatter) | XY_SCATTER |
|
| 44 |
+
| XY Lines | XY_SCATTER_LINES |
|
| 45 |
+
| XY Lines No Markers | XY_SCATTER_LINES_NO_MARKERS |
|
| 46 |
+
| XY Smooth Lines | XY_SCATTER_SMOOTH |
|
| 47 |
+
| XY Smooth No Markers | XY_SCATTER_SMOOTH_NO_MARKERS |
|
| 48 |
+
| Bubble | BUBBLE |
|
| 49 |
+
| 3D-Bubble | BUBBLE_THREE_D_EFFECT |
|
| 50 |
+
| Radar | RADAR |
|
| 51 |
+
| Marked Radar | RADAR_MARKERS |
|
| 52 |
+
| Filled Radar | RADAR_FILLED |
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
Scenario Outline: Get Chart.category_axis
|
| 56 |
+
Given a chart of type <chart-type>
|
| 57 |
+
Then chart.category_axis is a <type-name> object
|
| 58 |
+
|
| 59 |
+
Examples: category axis object types
|
| 60 |
+
| chart-type | type-name |
|
| 61 |
+
| Stacked Bar | CategoryAxis |
|
| 62 |
+
| Line (with date categories) | DateAxis |
|
| 63 |
+
| XY (Scatter) | ValueAxis |
|
| 64 |
+
| Bubble | ValueAxis |
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
Scenario: Chart.font
|
| 68 |
+
Given a Chart object as chart
|
| 69 |
+
Then chart.font is a Font object
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
Scenario Outline: Get Chart.has_title
|
| 73 |
+
Given a chart having <a-or-no> title
|
| 74 |
+
Then chart.has_title is <expected-value>
|
| 75 |
+
|
| 76 |
+
Examples: chart title presence cases
|
| 77 |
+
| a-or-no | expected-value |
|
| 78 |
+
| a | True |
|
| 79 |
+
| no | False |
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
Scenario Outline: Set Chart.has_title
|
| 83 |
+
Given a chart having <a-or-no> title
|
| 84 |
+
When I assign <value> to chart.has_title
|
| 85 |
+
Then chart.has_title is <expected-value>
|
| 86 |
+
|
| 87 |
+
Examples: chart title assignment cases
|
| 88 |
+
| a-or-no | value | expected-value |
|
| 89 |
+
| a | True | True |
|
| 90 |
+
| a | False | False |
|
| 91 |
+
| no | True | True |
|
| 92 |
+
| no | False | False |
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
Scenario Outline: Get Chart.value_axis
|
| 96 |
+
Given a chart of type <chart-type>
|
| 97 |
+
Then chart.value_axis is a ValueAxis object
|
| 98 |
+
|
| 99 |
+
Examples: value axis object types
|
| 100 |
+
| chart-type |
|
| 101 |
+
| Stacked Bar |
|
| 102 |
+
| XY (Scatter) |
|
| 103 |
+
| Bubble |
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
Scenario: Chart.series
|
| 107 |
+
Given a Chart object as chart
|
| 108 |
+
Then chart.series is a SeriesCollection object
|
tasks/tasksmith-74f059424102/tests/source/features/cht-charttitle-props.feature
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Chart Title properties
|
| 2 |
+
In order to customize the formatting of a chart title
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need read/write properties on ChartTitle
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: ChartTitle.format
|
| 8 |
+
Given a chart title
|
| 9 |
+
Then chart_title.format is a ChartFormat object
|
| 10 |
+
And chart_title.format.fill is a FillFormat object
|
| 11 |
+
And chart_title.format.line is a LineFormat object
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Scenario Outline: Get ChartTitle.has_text_frame
|
| 15 |
+
Given a chart title having <a-or-no> text frame
|
| 16 |
+
Then chart_title.has_text_frame is <value>
|
| 17 |
+
|
| 18 |
+
Examples: text frame presence cases
|
| 19 |
+
| a-or-no | value |
|
| 20 |
+
| a | True |
|
| 21 |
+
| no | False |
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
Scenario Outline: Set ChartTitle.has_text_frame
|
| 25 |
+
Given a chart title having <a-or-no> text frame
|
| 26 |
+
When I assign <new-value> to chart_title.has_text_frame
|
| 27 |
+
Then chart_title.has_text_frame is <value>
|
| 28 |
+
|
| 29 |
+
Examples: chart_title.has_text_frame assignment cases
|
| 30 |
+
| a-or-no | new-value | value |
|
| 31 |
+
| no | True | True |
|
| 32 |
+
| a | False | False |
|
| 33 |
+
| no | False | False |
|
| 34 |
+
| a | True | True |
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
Scenario Outline: Get ChartTitle.text_frame
|
| 38 |
+
Given a chart title having <a-or-no> text frame
|
| 39 |
+
Then chart_title.text_frame is a TextFrame object
|
| 40 |
+
|
| 41 |
+
Examples: text frame presence cases
|
| 42 |
+
| a-or-no |
|
| 43 |
+
| a |
|
| 44 |
+
| no |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-data-props.feature
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: chart_data properties
|
| 2 |
+
In order to compose data for a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need chart data transfer objects
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: CategoryChartData.categories getter
|
| 8 |
+
Given a CategoryChartData object
|
| 9 |
+
Then chart_data.categories is a Categories object
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Scenario: CategoryChartData.categories setter
|
| 13 |
+
Given a CategoryChartData object
|
| 14 |
+
When I assign ['a', 'b', 'c'] to chart_data.categories
|
| 15 |
+
Then [c.label for c in chart_data.categories] is ['a', 'b', 'c']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
Scenario: CategoryChartData.add_category()
|
| 19 |
+
Given a CategoryChartData object
|
| 20 |
+
Then chart_data.add_category(name) is a Category object
|
| 21 |
+
And chart_data.categories[-1] is the category
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
Scenario: CategoryChartData.add_series()
|
| 25 |
+
Given a CategoryChartData object
|
| 26 |
+
Then chart_data.add_series(name, values) is a CategorySeriesData object
|
| 27 |
+
And chart_data[-1] is the new series
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
Scenario: Category.add_sub_category()
|
| 31 |
+
Given a Category object
|
| 32 |
+
Then category.add_sub_category(name) is a Category object
|
| 33 |
+
And category.sub_categories[-1] is the new category
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
Scenario Outline: CategoryChartData number format
|
| 37 |
+
Given a CategoryChartData object with number format <cht-nf>
|
| 38 |
+
When I add a series with number format <ser-nf>
|
| 39 |
+
And I add a data point with number format <dp-nf>
|
| 40 |
+
Then chart_data.number_format is <cht-val>
|
| 41 |
+
And series_data.number_format is <ser-val>
|
| 42 |
+
And data_point.number_format is <dp-val>
|
| 43 |
+
|
| 44 |
+
Examples: number format inheritance states
|
| 45 |
+
| cht-nf | ser-nf | dp-nf | cht-val | ser-val | dp-val |
|
| 46 |
+
| None | None | None | General | General | General |
|
| 47 |
+
| None | None | 42 | General | General | 42 |
|
| 48 |
+
| None | 42 | None | General | 42 | 42 |
|
| 49 |
+
| None | 42 | 24 | General | 42 | 24 |
|
| 50 |
+
| 42 | None | None | 42 | 42 | 42 |
|
| 51 |
+
| 42 | None | 24 | 42 | 42 | 24 |
|
| 52 |
+
| 42 | 24 | None | 42 | 24 | 24 |
|
| 53 |
+
| 42 | 24 | 12 | 42 | 24 | 12 |
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
Scenario Outline: XyChartData number format
|
| 57 |
+
Given a XyChartData object with number format <cht-nf>
|
| 58 |
+
When I add a series with number format <ser-nf>
|
| 59 |
+
And I add an XY data point with number format <dp-nf>
|
| 60 |
+
Then chart_data.number_format is <cht-val>
|
| 61 |
+
And series_data.number_format is <ser-val>
|
| 62 |
+
And data_point.number_format is <dp-val>
|
| 63 |
+
|
| 64 |
+
Examples: number format inheritance states
|
| 65 |
+
| cht-nf | ser-nf | dp-nf | cht-val | ser-val | dp-val |
|
| 66 |
+
| None | None | None | General | General | General |
|
| 67 |
+
| None | None | 42 | General | General | 42 |
|
| 68 |
+
| None | 42 | None | General | 42 | 42 |
|
| 69 |
+
| None | 42 | 24 | General | 42 | 24 |
|
| 70 |
+
| 42 | None | None | 42 | 42 | 42 |
|
| 71 |
+
| 42 | None | 24 | 42 | 42 | 24 |
|
| 72 |
+
| 42 | 24 | None | 42 | 24 | 24 |
|
| 73 |
+
| 42 | 24 | 12 | 42 | 24 | 12 |
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
Scenario Outline: BubbleChartData number format
|
| 77 |
+
Given a BubbleChartData object with number format <cht-nf>
|
| 78 |
+
When I add a series with number format <ser-nf>
|
| 79 |
+
And I add a bubble data point with number format <dp-nf>
|
| 80 |
+
Then chart_data.number_format is <cht-val>
|
| 81 |
+
And series_data.number_format is <ser-val>
|
| 82 |
+
And data_point.number_format is <dp-val>
|
| 83 |
+
|
| 84 |
+
Examples: number format inheritance states
|
| 85 |
+
| cht-nf | ser-nf | dp-nf | cht-val | ser-val | dp-val |
|
| 86 |
+
| None | None | None | General | General | General |
|
| 87 |
+
| None | None | 42 | General | General | 42 |
|
| 88 |
+
| None | 42 | None | General | 42 | 42 |
|
| 89 |
+
| None | 42 | 24 | General | 42 | 24 |
|
| 90 |
+
| 42 | None | None | 42 | 42 | 42 |
|
| 91 |
+
| 42 | None | 24 | 42 | 42 | 24 |
|
| 92 |
+
| 42 | 24 | None | 42 | 24 | 24 |
|
| 93 |
+
| 42 | 24 | 12 | 42 | 24 | 12 |
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
Scenario Outline: Get Categories.number format
|
| 97 |
+
Given a Categories object with number format <initial-nf>
|
| 98 |
+
And the categories are of type <cat-type>
|
| 99 |
+
Then categories.number_format is <value>
|
| 100 |
+
|
| 101 |
+
Examples: number format inheritance states
|
| 102 |
+
| initial-nf | cat-type | value |
|
| 103 |
+
| left as default | str | General |
|
| 104 |
+
| left as default | int | General |
|
| 105 |
+
| left as default | date | yyyy\-mm\-dd |
|
| 106 |
+
| mmm-dd | date | mmm-dd |
|
| 107 |
+
| 0.0 | float | 0.0 |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-datalabels.feature
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Access and modify data labels properties
|
| 2 |
+
In order to customize the appearance of data labels on a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need access to data label objects and their properties
|
| 5 |
+
|
| 6 |
+
# ---DataLabels---
|
| 7 |
+
|
| 8 |
+
Scenario Outline: DataLabel.show_category_name getter
|
| 9 |
+
Given a DataLabels object <showing-or-not> category-name as data_labels
|
| 10 |
+
Then data_labels.show_category_name is <value>
|
| 11 |
+
|
| 12 |
+
Examples: data_label.show_category_name states
|
| 13 |
+
| showing-or-not | value |
|
| 14 |
+
| not showing | False |
|
| 15 |
+
| showing | True |
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
Scenario Outline: DataLabel.show_category_name setter
|
| 19 |
+
Given a DataLabels object <showing-or-not> category-name as data_labels
|
| 20 |
+
When I assign <value> to data_labels.show_category_name
|
| 21 |
+
Then data_labels.show_category_name is <value>
|
| 22 |
+
|
| 23 |
+
Examples: data_label.show_category_name states
|
| 24 |
+
| showing-or-not | value |
|
| 25 |
+
| not showing | True |
|
| 26 |
+
| showing | False |
|
| 27 |
+
| not showing | False |
|
| 28 |
+
| showing | True |
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
Scenario Outline: DataLabel.show_legend_key getter
|
| 32 |
+
Given a DataLabels object <showing-or-not> legend-key as data_labels
|
| 33 |
+
Then data_labels.show_legend_key is <value>
|
| 34 |
+
|
| 35 |
+
Examples: data_label.show_legend_key states
|
| 36 |
+
| showing-or-not | value |
|
| 37 |
+
| not showing | False |
|
| 38 |
+
| showing | True |
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
Scenario Outline: DataLabel.show_legend_key setter
|
| 42 |
+
Given a DataLabels object <showing-or-not> legend-key as data_labels
|
| 43 |
+
When I assign <value> to data_labels.show_legend_key
|
| 44 |
+
Then data_labels.show_legend_key is <value>
|
| 45 |
+
|
| 46 |
+
Examples: data_label.show_legend_key states
|
| 47 |
+
| showing-or-not | value |
|
| 48 |
+
| not showing | True |
|
| 49 |
+
| showing | False |
|
| 50 |
+
| not showing | False |
|
| 51 |
+
| showing | True |
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
Scenario Outline: DataLabel.show_percentage getter
|
| 55 |
+
Given a DataLabels object <showing-or-not> percentage as data_labels
|
| 56 |
+
Then data_labels.show_percentage is <value>
|
| 57 |
+
|
| 58 |
+
Examples: data_label.show_percentage states
|
| 59 |
+
| showing-or-not | value |
|
| 60 |
+
| not showing | False |
|
| 61 |
+
| showing | True |
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
Scenario Outline: DataLabel.show_percentage setter
|
| 65 |
+
Given a DataLabels object <showing-or-not> percentage as data_labels
|
| 66 |
+
When I assign <value> to data_labels.show_percentage
|
| 67 |
+
Then data_labels.show_percentage is <value>
|
| 68 |
+
|
| 69 |
+
Examples: data_label.show_percentage states
|
| 70 |
+
| showing-or-not | value |
|
| 71 |
+
| not showing | True |
|
| 72 |
+
| showing | False |
|
| 73 |
+
| not showing | False |
|
| 74 |
+
| showing | True |
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
Scenario Outline: DataLabel.show_series_name getter
|
| 78 |
+
Given a DataLabels object <showing-or-not> series-name as data_labels
|
| 79 |
+
Then data_labels.show_series_name is <value>
|
| 80 |
+
|
| 81 |
+
Examples: data_label.show_series_name states
|
| 82 |
+
| showing-or-not | value |
|
| 83 |
+
| not showing | False |
|
| 84 |
+
| showing | True |
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
Scenario Outline: DataLabel.show_series_name setter
|
| 88 |
+
Given a DataLabels object <showing-or-not> series-name as data_labels
|
| 89 |
+
When I assign <value> to data_labels.show_series_name
|
| 90 |
+
Then data_labels.show_series_name is <value>
|
| 91 |
+
|
| 92 |
+
Examples: data_label.show_series_name states
|
| 93 |
+
| showing-or-not | value |
|
| 94 |
+
| not showing | True |
|
| 95 |
+
| showing | False |
|
| 96 |
+
| not showing | False |
|
| 97 |
+
| showing | True |
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
Scenario Outline: DataLabel.show_value getter
|
| 101 |
+
Given a DataLabels object <showing-or-not> value as data_labels
|
| 102 |
+
Then data_labels.show_series_name is <value>
|
| 103 |
+
|
| 104 |
+
Examples: data_label.show_value states
|
| 105 |
+
| showing-or-not | value |
|
| 106 |
+
| not showing | False |
|
| 107 |
+
| showing | True |
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
Scenario Outline: DataLabel.show_value setter
|
| 111 |
+
Given a DataLabels object <showing-or-not> value as data_labels
|
| 112 |
+
When I assign <value> to data_labels.show_value
|
| 113 |
+
Then data_labels.show_value is <value>
|
| 114 |
+
|
| 115 |
+
Examples: data_label.show_value states
|
| 116 |
+
| showing-or-not | value |
|
| 117 |
+
| not showing | True |
|
| 118 |
+
| showing | False |
|
| 119 |
+
| not showing | False |
|
| 120 |
+
| showing | True |
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
Scenario Outline: DataLabels.position getter
|
| 124 |
+
Given a DataLabels object with <position> position as data_labels
|
| 125 |
+
Then data_labels.position is <expected-value>
|
| 126 |
+
|
| 127 |
+
Examples: data_labels position values
|
| 128 |
+
| position | expected-value |
|
| 129 |
+
| inherited | None |
|
| 130 |
+
| inside-base | INSIDE_BASE |
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
Scenario Outline: DataLabels.position setter
|
| 134 |
+
Given a DataLabels object with <position> position as data_labels
|
| 135 |
+
When I assign <new-value> to data_labels.position
|
| 136 |
+
Then data_labels.position is <expected-value>
|
| 137 |
+
|
| 138 |
+
Examples: expected results of assignment to data_labels.position
|
| 139 |
+
| position | new-value | expected-value |
|
| 140 |
+
| inherited | INSIDE_END | INSIDE_END |
|
| 141 |
+
| inside-base | OUTSIDE_END | OUTSIDE_END |
|
| 142 |
+
| inside-base | None | None |
|
| 143 |
+
|
| 144 |
+
# ---DataLabel---
|
| 145 |
+
|
| 146 |
+
Scenario Outline: DataLabel.font
|
| 147 |
+
Given a data label <having-or-not> custom font as data_label
|
| 148 |
+
Then data_label.font is a Font object
|
| 149 |
+
|
| 150 |
+
Examples: data_label.font states
|
| 151 |
+
| having-or-not |
|
| 152 |
+
| having a |
|
| 153 |
+
| having no |
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
Scenario Outline: DataLabel.has_text_frame getter
|
| 157 |
+
Given a data label <having-or-not> custom text as data_label
|
| 158 |
+
Then data_label.has_text_frame is <value>
|
| 159 |
+
|
| 160 |
+
Examples: text frame presence cases
|
| 161 |
+
| having-or-not | value |
|
| 162 |
+
| having | True |
|
| 163 |
+
| having no | False |
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
Scenario Outline: DataLabel.has_text_frame setter
|
| 167 |
+
Given a data label <having-or-not> custom text as data_label
|
| 168 |
+
When I assign <new-value> to data_label.has_text_frame
|
| 169 |
+
Then data_label.has_text_frame is <value>
|
| 170 |
+
|
| 171 |
+
Examples: data_label.has_text_frame assignment cases
|
| 172 |
+
| having-or-not | new-value | value |
|
| 173 |
+
| having no | True | True |
|
| 174 |
+
| having | False | False |
|
| 175 |
+
| having no | False | False |
|
| 176 |
+
| having | True | True |
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
Scenario Outline: DataLabel.position getter
|
| 180 |
+
Given a data label with <position> position as data_label
|
| 181 |
+
Then data_label.position is <value>
|
| 182 |
+
|
| 183 |
+
Examples: data_label.position cases
|
| 184 |
+
| position | value |
|
| 185 |
+
| inherited | None |
|
| 186 |
+
| centered | CENTER |
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
Scenario Outline: DataLabel.position setter
|
| 190 |
+
Given a data label with <position> position as data_label
|
| 191 |
+
When I assign <value> to data_label.position
|
| 192 |
+
Then data_label.position is <value>
|
| 193 |
+
|
| 194 |
+
Examples: data_label.position assignment cases
|
| 195 |
+
| position | value |
|
| 196 |
+
| inherited | CENTER |
|
| 197 |
+
| centered | BELOW |
|
| 198 |
+
| below | None |
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
Scenario Outline: DataLabel.text_frame
|
| 202 |
+
Given a data label <having-or-not> custom text as data_label
|
| 203 |
+
Then data_label.text_frame is a TextFrame object
|
| 204 |
+
|
| 205 |
+
Examples: text frame presence cases
|
| 206 |
+
| having-or-not |
|
| 207 |
+
| having |
|
| 208 |
+
| having no |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-gridlines-props.feature
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Gridlines properties
|
| 2 |
+
To customize the formatting of chart gridlines
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need read/write properties on major and minor gridlines objects
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: Get gridlines.format
|
| 8 |
+
Given a major gridlines
|
| 9 |
+
Then gridlines.format is a ChartFormat object
|
| 10 |
+
And gridlines.format.fill is a FillFormat object
|
| 11 |
+
And gridlines.format.line is a LineFormat object
|
tasks/tasksmith-74f059424102/tests/source/features/cht-legend-access.feature
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Access chart legend
|
| 2 |
+
In order to customize the legend for a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need a way to access the chart legend
|
| 5 |
+
|
| 6 |
+
Scenario Outline: Determine presence of legend
|
| 7 |
+
Given a chart <having-or-not> a legend
|
| 8 |
+
Then chart.has_legend is <expected-value>
|
| 9 |
+
|
| 10 |
+
Examples: chart.has_legend states
|
| 11 |
+
| having-or-not | expected-value |
|
| 12 |
+
| having | True |
|
| 13 |
+
| not having | False |
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
Scenario Outline: Adding a legend
|
| 17 |
+
Given a chart <having-or-not> a legend
|
| 18 |
+
When I assign <value> to chart.has_legend
|
| 19 |
+
Then chart.has_legend is <expected-value>
|
| 20 |
+
|
| 21 |
+
Examples: chart.has_legend states
|
| 22 |
+
| having-or-not | value | expected-value |
|
| 23 |
+
| having | False | False |
|
| 24 |
+
| not having | True | True |
|
| 25 |
+
| having | True | True |
|
| 26 |
+
| not having | False | False |
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
Scenario: Access legend object of chart
|
| 30 |
+
Given a chart having a legend
|
| 31 |
+
Then chart.legend is a legend object
|
tasks/tasksmith-74f059424102/tests/source/features/cht-legend-props.feature
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Get and set legend properties
|
| 2 |
+
In order to customize the appearance of the legend on a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need a way to get and set legend properties
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: Access legend font
|
| 8 |
+
Given a legend
|
| 9 |
+
Then legend.font is a Font object
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Scenario Outline: Determine legend horizontal offset
|
| 13 |
+
Given a legend having horizontal offset of <value>
|
| 14 |
+
Then legend.horz_offset is <expected-value>
|
| 15 |
+
|
| 16 |
+
Examples: legend horizontal offset values
|
| 17 |
+
| value | expected-value |
|
| 18 |
+
| none | 0.0 |
|
| 19 |
+
| -0.5 | -0.5 |
|
| 20 |
+
| 0.42 | 0.42 |
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
Scenario Outline: Change legend horizontal offset
|
| 24 |
+
Given a legend having horizontal offset of <value>
|
| 25 |
+
When I assign <new-value> to legend.horz_offset
|
| 26 |
+
Then legend.horz_offset is <expected-value>
|
| 27 |
+
|
| 28 |
+
Examples: expected results of changing horz_offset
|
| 29 |
+
| value | new-value | expected-value |
|
| 30 |
+
| none | -1.0 | -1.0 |
|
| 31 |
+
| -0.5 | 0.5 | 0.5 |
|
| 32 |
+
| 0.42 | -0.5 | -0.5 |
|
| 33 |
+
| -0.5 | 0 | 0.0 |
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
Scenario Outline: Determine whether the legend is beside or overlays the chart
|
| 37 |
+
Given a legend with overlay setting of <setting>
|
| 38 |
+
Then legend.include_in_layout is <expected-value>
|
| 39 |
+
|
| 40 |
+
Examples: legend.include_in_layout expected values
|
| 41 |
+
| setting | expected-value |
|
| 42 |
+
| no explicit setting | True |
|
| 43 |
+
| True | True |
|
| 44 |
+
| False | False |
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
Scenario Outline: Change whether the legend is beside or overlays the chart
|
| 48 |
+
Given a legend with overlay setting of <setting>
|
| 49 |
+
When I assign <value> to legend.include_in_layout
|
| 50 |
+
Then legend.include_in_layout is <expected-value>
|
| 51 |
+
|
| 52 |
+
Examples: expected results of changing legend.include_in_layout
|
| 53 |
+
| setting | value | expected-value |
|
| 54 |
+
| no explicit setting | True | True |
|
| 55 |
+
| no explicit setting | False | False |
|
| 56 |
+
| True | False | False |
|
| 57 |
+
| True | True | True |
|
| 58 |
+
| False | True | True |
|
| 59 |
+
| False | False | False |
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
Scenario Outline: Determine legend position
|
| 63 |
+
Given a legend positioned <location> the chart
|
| 64 |
+
Then legend.position is <expected-value>
|
| 65 |
+
|
| 66 |
+
Examples: legend position values
|
| 67 |
+
| location | expected-value |
|
| 68 |
+
| at an unspecified location of | RIGHT |
|
| 69 |
+
| below | BOTTOM |
|
| 70 |
+
| to the right of | RIGHT |
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
Scenario Outline: Change legend position
|
| 74 |
+
Given a legend positioned <location> the chart
|
| 75 |
+
When I assign <new-value> to legend.position
|
| 76 |
+
Then legend.position is <expected-value>
|
| 77 |
+
|
| 78 |
+
Examples: expected results of changing legend.position
|
| 79 |
+
| location | new-value | expected-value |
|
| 80 |
+
| at an unspecified location of | RIGHT | RIGHT |
|
| 81 |
+
| below | TOP | TOP |
|
| 82 |
+
| to the right of | BOTTOM | BOTTOM |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-marker-props.feature
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Get and set marker properties
|
| 2 |
+
In order to customize the visual display of a data point marker
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need a way to get and set marker properties
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: Get Marker.format
|
| 8 |
+
Given a marker
|
| 9 |
+
Then marker.format is a ChartFormat object
|
| 10 |
+
And marker.format.fill is a FillFormat object
|
| 11 |
+
And marker.format.line is a LineFormat object
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Scenario Outline: Get Marker.size
|
| 15 |
+
Given a marker having size of <size>
|
| 16 |
+
Then marker.size is <value>
|
| 17 |
+
|
| 18 |
+
Examples: Marker size value cases
|
| 19 |
+
| size | value |
|
| 20 |
+
| no explicit value | None |
|
| 21 |
+
| 24 points | 24 |
|
| 22 |
+
| 36 points | 36 |
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
Scenario Outline: Set Marker.size
|
| 26 |
+
Given a marker having size of <size>
|
| 27 |
+
When I assign <value> to marker.size
|
| 28 |
+
Then marker.size is <value>
|
| 29 |
+
|
| 30 |
+
Examples: Marker size value cases
|
| 31 |
+
| size | value |
|
| 32 |
+
| no explicit value | 24 |
|
| 33 |
+
| 24 points | 36 |
|
| 34 |
+
| 36 points | None |
|
| 35 |
+
| no explicit value | None |
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
Scenario Outline: Get Marker.style
|
| 39 |
+
Given a marker having style of <shape>
|
| 40 |
+
Then marker.style is <value>
|
| 41 |
+
|
| 42 |
+
Examples: Marker shape value cases
|
| 43 |
+
| shape | value |
|
| 44 |
+
| no explicit value | None |
|
| 45 |
+
| circle | CIRCLE |
|
| 46 |
+
| triangle | TRIANGLE |
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
Scenario Outline: Set Marker.style
|
| 50 |
+
Given a marker having style of <style>
|
| 51 |
+
When I assign <value> to marker.style
|
| 52 |
+
Then marker.style is <value>
|
| 53 |
+
|
| 54 |
+
Examples: Marker style value cases
|
| 55 |
+
| style | value |
|
| 56 |
+
| no explicit value | CIRCLE |
|
| 57 |
+
| circle | TRIANGLE |
|
| 58 |
+
| triangle | None |
|
| 59 |
+
| no explicit value | None |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-plot-props.feature
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Plot properties
|
| 2 |
+
To customize the formatting of a plot on a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need read/write properties on plot objects
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: Get bubble_plot.bubble_scale
|
| 8 |
+
Given a bubble plot having bubble scale of <percent>
|
| 9 |
+
Then bubble_plot.bubble_scale is <value>
|
| 10 |
+
|
| 11 |
+
Examples: bubble_plot.bubble_scale values
|
| 12 |
+
| percent | value |
|
| 13 |
+
| no explicit value | 100 |
|
| 14 |
+
| 70% | 70 |
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Scenario Outline: Set bubble_plot.bubble_scale
|
| 18 |
+
Given a bubble plot having bubble scale of <percent>
|
| 19 |
+
When I assign <new-value> to bubble_plot.bubble_scale
|
| 20 |
+
Then bubble_plot.bubble_scale is <value>
|
| 21 |
+
|
| 22 |
+
Examples: bubble_plot.bubble_scale assignment cases
|
| 23 |
+
| percent | new-value | value |
|
| 24 |
+
| no explicit value | 70 | 70 |
|
| 25 |
+
| 70% | 150 | 150 |
|
| 26 |
+
| 70% | None | 100 |
|
| 27 |
+
| no explicit value | None | 100 |
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
Scenario: Get category_plot.categories
|
| 31 |
+
Given a category plot
|
| 32 |
+
Then plot.categories is a Categories object
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
Scenario Outline: Get plot.has_data_labels
|
| 36 |
+
Given a bar plot <having-or-not> data labels
|
| 37 |
+
Then plot.has_data_labels is <expected-value>
|
| 38 |
+
|
| 39 |
+
Examples: having data labels or not
|
| 40 |
+
| having-or-not | expected-value |
|
| 41 |
+
| having | True |
|
| 42 |
+
| not having | False |
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
Scenario Outline: Set plot.has_data_labels
|
| 46 |
+
Given a bar plot <having-or-not> data labels
|
| 47 |
+
When I assign <value> to plot.has_data_labels
|
| 48 |
+
Then plot.has_data_labels is <expected-value>
|
| 49 |
+
|
| 50 |
+
Examples: expected results of changing has_data_labels
|
| 51 |
+
| having-or-not | value | expected-value |
|
| 52 |
+
| having | False | False |
|
| 53 |
+
| having | True | True |
|
| 54 |
+
| not having | False | False |
|
| 55 |
+
| not having | True | True |
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
Scenario Outline: Get bar_plot.gap_width
|
| 59 |
+
Given a bar plot having gap width of <gap-width>
|
| 60 |
+
Then plot.gap_width is <expected-value>
|
| 61 |
+
|
| 62 |
+
Examples: bar plot gap widths
|
| 63 |
+
| gap-width | expected-value |
|
| 64 |
+
| no explicit value | 150 |
|
| 65 |
+
| 300 | 300 |
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
Scenario Outline: Set bar_plot.gap_width
|
| 69 |
+
Given a bar plot having gap width of <gap-width>
|
| 70 |
+
When I assign <new-value> to plot.gap_width
|
| 71 |
+
Then plot.gap_width is <expected-value>
|
| 72 |
+
|
| 73 |
+
Examples: expected results of changing gap width
|
| 74 |
+
| gap-width | new-value | expected-value |
|
| 75 |
+
| no explicit value | 300 | 300 |
|
| 76 |
+
| 300 | 275 | 275 |
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
Scenario Outline: Get bar_plot.overlap
|
| 80 |
+
Given a bar plot having overlap of <overlap>
|
| 81 |
+
Then plot.overlap is <expected-value>
|
| 82 |
+
|
| 83 |
+
Examples: expected bar plot overlap values
|
| 84 |
+
| overlap | expected-value |
|
| 85 |
+
| no explicit value | 0 |
|
| 86 |
+
| 42 | 42 |
|
| 87 |
+
| -42 | -42 |
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
Scenario Outline: Set bar_plot.overlap
|
| 91 |
+
Given a bar plot having overlap of <overlap>
|
| 92 |
+
When I assign <new-value> to plot.overlap
|
| 93 |
+
Then plot.overlap is <expected-value>
|
| 94 |
+
|
| 95 |
+
Examples: expected results of changing overlap
|
| 96 |
+
| overlap | new-value | expected-value |
|
| 97 |
+
| no explicit value | 42 | 42 |
|
| 98 |
+
| 42 | -42 | -42 |
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
Scenario Outline: Get plot.vary_by_categories
|
| 102 |
+
Given a bar plot having vary color by category set to <setting>
|
| 103 |
+
Then plot.vary_by_categories is <expected-value>
|
| 104 |
+
|
| 105 |
+
Examples: expected Plot.vary_by_categories values
|
| 106 |
+
| setting | expected-value |
|
| 107 |
+
| no explicit setting | True |
|
| 108 |
+
| True | True |
|
| 109 |
+
| False | False |
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
Scenario Outline: Set plot.vary_by_categories
|
| 113 |
+
Given a bar plot having vary color by category set to <setting>
|
| 114 |
+
When I assign <value> to plot.vary_by_categories
|
| 115 |
+
Then plot.vary_by_categories is <expected-value>
|
| 116 |
+
|
| 117 |
+
Examples: expected Plot.vary_by_categories values
|
| 118 |
+
| setting | value | expected-value |
|
| 119 |
+
| no explicit setting | False | False |
|
| 120 |
+
| True | False | False |
|
| 121 |
+
| False | True | True |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-point-access.feature
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Access a point
|
| 2 |
+
In order to operate on an individual data point
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need sequence operations on xPoints objects
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: Points.__len__()
|
| 8 |
+
Given a <type> object containing 3 points
|
| 9 |
+
Then len(points) is 3
|
| 10 |
+
|
| 11 |
+
Examples: point container types
|
| 12 |
+
| type |
|
| 13 |
+
| XyPoints |
|
| 14 |
+
| BubblePoints |
|
| 15 |
+
| CategoryPoints |
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
Scenario Outline: Points.__getitem__()
|
| 19 |
+
Given a <type> object containing 3 points
|
| 20 |
+
Then points[2] is a Point object
|
| 21 |
+
|
| 22 |
+
Examples: point container types
|
| 23 |
+
| type |
|
| 24 |
+
| XyPoints |
|
| 25 |
+
| BubblePoints |
|
| 26 |
+
| CategoryPoints |
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
Scenario Outline: Points.__iter__()
|
| 30 |
+
Given a <type> object containing 3 points
|
| 31 |
+
Then iterating points produces 3 Point objects
|
| 32 |
+
|
| 33 |
+
Examples: point container types
|
| 34 |
+
| type |
|
| 35 |
+
| XyPoints |
|
| 36 |
+
| BubblePoints |
|
| 37 |
+
| CategoryPoints |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-point-props.feature
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Get and set point properties
|
| 2 |
+
In order to customize the formatting of a data point
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need a way to get and set point properties
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: Get Point.data_label
|
| 8 |
+
Given a point
|
| 9 |
+
Then point.data_label is a DataLabel object
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Scenario: Get Point.format
|
| 13 |
+
Given a point
|
| 14 |
+
Then point.format is a ChartFormat object
|
| 15 |
+
And point.format.fill is a FillFormat object
|
| 16 |
+
And point.format.line is a LineFormat object
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
Scenario: Get Point.marker
|
| 20 |
+
Given a point
|
| 21 |
+
Then point.marker is a Marker object
|
tasks/tasksmith-74f059424102/tests/source/features/cht-replace-data.feature
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Replace chart data
|
| 2 |
+
In order to update the data for a chart while retaining its formatting
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need a way to replace the data of a chart
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: Replace category chart data
|
| 8 |
+
Given a chart of size and type <spec>
|
| 9 |
+
When I replace its data with <cats> categories and <sers> series
|
| 10 |
+
Then len(plot.categories) is <cats>
|
| 11 |
+
And len(chart.series) is <sers>
|
| 12 |
+
And len(series.values) is <cats> for each series
|
| 13 |
+
And each series has a new name
|
| 14 |
+
And the chart has new chart data
|
| 15 |
+
|
| 16 |
+
Examples: Replacement chart data
|
| 17 |
+
| spec | cats | sers |
|
| 18 |
+
| 2x2 Clustered Bar | 3 | 3 |
|
| 19 |
+
| 2x2 100% Stacked Bar | 3 | 3 |
|
| 20 |
+
| 2x2 Clustered Column | 3 | 3 |
|
| 21 |
+
| 4x3 Line | 3 | 2 |
|
| 22 |
+
| 3x1 Pie | 5 | 1 |
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
Scenario: Replace XY chart data
|
| 26 |
+
Given a chart of size and type 3x2 XY
|
| 27 |
+
When I replace its data with 3 series of 3 points each
|
| 28 |
+
Then len(chart.series) is 3
|
| 29 |
+
And len(series.values) is 3 for each series
|
| 30 |
+
And each series has a new name
|
| 31 |
+
And the chart has new chart data
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
Scenario: Replace Bubble chart data
|
| 35 |
+
Given a chart of size and type 3x2 Bubble
|
| 36 |
+
When I replace its data with 3 series of 3 bubble points each
|
| 37 |
+
Then len(chart.series) is 3
|
| 38 |
+
And len(series.values) is 3 for each series
|
| 39 |
+
And each series has a new name
|
| 40 |
+
And the chart has new chart data
|
tasks/tasksmith-74f059424102/tests/source/features/cht-series.feature
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Chart series
|
| 2 |
+
In order to customize the formatting of a series on a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need access to series objects and their properties
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: SeriesCollection.__len__()
|
| 8 |
+
Given a SeriesCollection object for a <container> having <count> series
|
| 9 |
+
Then len(series_collection) is <count>
|
| 10 |
+
|
| 11 |
+
Examples: series container types
|
| 12 |
+
| container | count |
|
| 13 |
+
| single-plot chart | 3 |
|
| 14 |
+
| multi-plot chart | 5 |
|
| 15 |
+
| plot | 3 |
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
Scenario Outline: SeriesCollection.__getitem__()
|
| 19 |
+
Given a SeriesCollection object for a <container> having <count> series
|
| 20 |
+
Then series_collection[2] is a Series object
|
| 21 |
+
|
| 22 |
+
Examples: series container types
|
| 23 |
+
| container | count |
|
| 24 |
+
| single-plot chart | 3 |
|
| 25 |
+
| multi-plot chart | 5 |
|
| 26 |
+
| plot | 3 |
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
Scenario Outline: SeriesCollection.__iter__()
|
| 30 |
+
Given a SeriesCollection object for a <container> having <count> series
|
| 31 |
+
Then iterating series_collection produces <count> Series objects
|
| 32 |
+
|
| 33 |
+
Examples: series container types
|
| 34 |
+
| container | count |
|
| 35 |
+
| single-plot chart | 3 |
|
| 36 |
+
| multi-plot chart | 5 |
|
| 37 |
+
| plot | 3 |
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
Scenario Outline: series.data_labels
|
| 41 |
+
Given a <series-type>Series object as series
|
| 42 |
+
Then series.data_labels is a DataLabels object
|
| 43 |
+
|
| 44 |
+
Examples: Series types
|
| 45 |
+
| series-type |
|
| 46 |
+
| Area |
|
| 47 |
+
| Bar |
|
| 48 |
+
| Doughnut |
|
| 49 |
+
| Line |
|
| 50 |
+
| Pie |
|
| 51 |
+
| Radar |
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
Scenario Outline: BarSeries.invert_if_negative value
|
| 55 |
+
Given a BarSeries object having invert_if_negative of <setting> as series
|
| 56 |
+
Then series.invert_if_negative is <expected-value>
|
| 57 |
+
|
| 58 |
+
Examples: invert_if_negative settings
|
| 59 |
+
| setting | expected-value |
|
| 60 |
+
| no explicit setting | True |
|
| 61 |
+
| True | True |
|
| 62 |
+
| False | False |
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
Scenario Outline: BarSeries.invert_if_negative setter
|
| 66 |
+
Given a BarSeries object having invert_if_negative of <setting> as series
|
| 67 |
+
When I assign <new-value> to series.invert_if_negative
|
| 68 |
+
Then series.invert_if_negative is <expected-value>
|
| 69 |
+
|
| 70 |
+
Examples: invert_if_negative settings
|
| 71 |
+
| setting | new-value | expected-value |
|
| 72 |
+
| no explicit setting | True | True |
|
| 73 |
+
| no explicit setting | False | False |
|
| 74 |
+
| True | True | True |
|
| 75 |
+
| False | False | False |
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
Scenario: series.format
|
| 79 |
+
Given a series
|
| 80 |
+
Then series.format is a ChartFormat object
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
Scenario Outline: series.format.fill.type
|
| 84 |
+
Given a BarSeries object having <fill> fill as series
|
| 85 |
+
Then series.format.fill.type is <expected-fill-type>
|
| 86 |
+
|
| 87 |
+
Examples: Fill types
|
| 88 |
+
| fill | expected-fill-type |
|
| 89 |
+
| Automatic | None |
|
| 90 |
+
| No Fill | MSO_FILL_TYPE.BACKGROUND |
|
| 91 |
+
| Accent 1 | MSO_FILL_TYPE.SOLID |
|
| 92 |
+
| Orange | MSO_FILL_TYPE.SOLID |
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
Scenario: series.format.fill.fore_color.rgb
|
| 96 |
+
Given a BarSeries object having Orange fill as series
|
| 97 |
+
Then series.format.fill.fore_color.rgb is FF6600
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
Scenario: series.format.fill.fore_color.theme_color
|
| 101 |
+
Given a BarSeries object having Accent 1 fill as series
|
| 102 |
+
Then series.format.fill.fore_color.theme_color is Accent 1
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
Scenario Outline: series.format.line.width
|
| 106 |
+
Given a BarSeries object having <width> line as series
|
| 107 |
+
Then series.format.line.width is <expected-width>
|
| 108 |
+
|
| 109 |
+
Examples: line widths
|
| 110 |
+
| width | expected-width |
|
| 111 |
+
| no | 0 |
|
| 112 |
+
| 1 point | 12700 |
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
Scenario Outline: series.marker
|
| 116 |
+
Given a <series-type>Series object as series
|
| 117 |
+
Then series.marker is a Marker object
|
| 118 |
+
|
| 119 |
+
Examples: Series types having .marker property
|
| 120 |
+
| series-type |
|
| 121 |
+
| Line |
|
| 122 |
+
| Xy |
|
| 123 |
+
| Radar |
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
Scenario Outline: series.points
|
| 127 |
+
Given a <series-type>Series object as series
|
| 128 |
+
Then series.points is a <type-name> object
|
| 129 |
+
|
| 130 |
+
Examples: series points classes
|
| 131 |
+
| series-type | type-name |
|
| 132 |
+
| Xy | XyPoints |
|
| 133 |
+
| Bubble | BubblePoints |
|
| 134 |
+
| Category | CategoryPoints |
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
Scenario Outline: series.values
|
| 138 |
+
Given a BarSeries object having values <values> as series
|
| 139 |
+
Then series.values is <expected-value>
|
| 140 |
+
|
| 141 |
+
Examples: series values
|
| 142 |
+
| values | expected-value |
|
| 143 |
+
| 1.2, 2.3, 3.4 | (1.2, 2.3, 3.4) |
|
| 144 |
+
| 4.5, None, 6.7 | (4.5, None, 6.7) |
|
tasks/tasksmith-74f059424102/tests/source/features/cht-ticklabels-props.feature
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Get and set tick label properties
|
| 2 |
+
In order to customize the appearance of the tick labels on a chart
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need a way to get and set tick label properties
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: Access tick label offset for an axis
|
| 8 |
+
Given tick labels having an offset of <xml-value>
|
| 9 |
+
Then tick_labels.offset is <expected-value>
|
| 10 |
+
|
| 11 |
+
Examples: expected values of TickLabels.offset
|
| 12 |
+
| xml-value | expected-value |
|
| 13 |
+
| no explicit setting | 100 |
|
| 14 |
+
| 420 | 420 |
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Scenario Outline: Change tick label offset
|
| 18 |
+
Given tick labels having an offset of <xml-value>
|
| 19 |
+
When I assign <new-value> to tick_labels.offset
|
| 20 |
+
Then tick_labels.offset is <new-value>
|
| 21 |
+
|
| 22 |
+
Examples: expected values of TickLabels.offset
|
| 23 |
+
| xml-value | new-value |
|
| 24 |
+
| no explicit setting | 100 |
|
| 25 |
+
| no explicit setting | 420 |
|
| 26 |
+
| 420 | 100 |
|
tasks/tasksmith-74f059424102/tests/source/features/dml-color.feature
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Control color
|
| 2 |
+
In order to fine-tune the color of filled areas and lines
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need properties and methods on ColorFormat
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: ColorFormat.rgb
|
| 8 |
+
Given a ColorFormat object as color
|
| 9 |
+
When I assign RGBColor(12, 34, 56) to color.rgb
|
| 10 |
+
Then color.rgb is RGBColor(12, 34, 56)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
Scenario: ColorFormat.theme_color
|
| 14 |
+
Given a ColorFormat object as color
|
| 15 |
+
When I assign MSO_THEME_COLOR.ACCENT_6 to color.theme_color
|
| 16 |
+
Then color.theme_color is MSO_THEME_COLOR.ACCENT_6
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
Scenario: ColorFormat.brightness
|
| 20 |
+
Given a ColorFormat object as color
|
| 21 |
+
When I assign 0.42 to color.brightness
|
| 22 |
+
Then color.brightness is 0.42
|
tasks/tasksmith-74f059424102/tests/source/features/dml-effect.feature
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: ShadowFormat
|
| 2 |
+
In order to adjust a shadow effect
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need properties and methods on ShadowFormat
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: ShadowFormat.inherit getter
|
| 8 |
+
Given a ShadowFormat object that <inherits-or-not> as shadow
|
| 9 |
+
Then shadow.inherit is <value>
|
| 10 |
+
|
| 11 |
+
Examples: shadow inheritance cases
|
| 12 |
+
| inherits-or-not | value |
|
| 13 |
+
| inherits | True |
|
| 14 |
+
| does not inherit | False |
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Scenario Outline: ShadowFormat.inherit setter
|
| 18 |
+
Given a ShadowFormat object that <inherits-or-not> as shadow
|
| 19 |
+
When I assign <new-value> to shadow.inherit
|
| 20 |
+
Then shadow.inherit is <value>
|
| 21 |
+
|
| 22 |
+
Examples: shadow inheritance assignment cases
|
| 23 |
+
| inherits-or-not | new-value | value |
|
| 24 |
+
| inherits | False | False |
|
| 25 |
+
| does not inherit | True | True |
|
| 26 |
+
| inherits | None | False |
|
| 27 |
+
| inherits | True | True |
|
| 28 |
+
| does not inherit | None | False |
|
| 29 |
+
| does not inherit | False | False |
|
tasks/tasksmith-74f059424102/tests/source/features/dml-fill.feature
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Control fill
|
| 2 |
+
In order to fine-tune the visual experience of filled areas
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need properties and methods on FillFormat
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario Outline: FillFormat type getters
|
| 8 |
+
Given <type> FillFormat object as fill
|
| 9 |
+
Then fill.type == <value>
|
| 10 |
+
|
| 11 |
+
Examples: Fill types
|
| 12 |
+
| type | value |
|
| 13 |
+
| an inheriting | None |
|
| 14 |
+
| a no-fill | MSO_FILL.BACKGROUND |
|
| 15 |
+
| a solid | MSO_FILL.SOLID |
|
| 16 |
+
| a picture | MSO_FILL.PICTURE |
|
| 17 |
+
| a gradient | MSO_FILL.GRADIENT |
|
| 18 |
+
| a patterned | MSO_FILL.PATTERNED |
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
Scenario Outline: FillFormat type setters
|
| 22 |
+
Given a FillFormat object as fill
|
| 23 |
+
When I call fill.<type-setter>()
|
| 24 |
+
Then fill.type == <value>
|
| 25 |
+
|
| 26 |
+
Examples: Fill types
|
| 27 |
+
| type-setter | value |
|
| 28 |
+
| background | MSO_FILL.BACKGROUND |
|
| 29 |
+
| gradient | MSO_FILL.GRADIENT |
|
| 30 |
+
| solid | MSO_FILL.SOLID |
|
| 31 |
+
| patterned | MSO_FILL.PATTERNED |
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
Scenario: FillFormat.back_color
|
| 35 |
+
Given a FillFormat object as fill
|
| 36 |
+
When I call fill.patterned()
|
| 37 |
+
Then fill.back_color is a ColorFormat object
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
Scenario Outline: FillFormat.fore_color
|
| 41 |
+
Given a FillFormat object as fill
|
| 42 |
+
When I call fill.<type-setter>()
|
| 43 |
+
Then fill.fore_color is a ColorFormat object
|
| 44 |
+
|
| 45 |
+
Examples: Fill types
|
| 46 |
+
| type-setter |
|
| 47 |
+
| patterned |
|
| 48 |
+
| solid |
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
Scenario: FillFormat.gradient_angle getter
|
| 52 |
+
Given a gradient FillFormat object as fill
|
| 53 |
+
Then fill.gradient_angle == 90.0
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
Scenario Outline: FillFormat.gradient_angle setter
|
| 57 |
+
Given a gradient FillFormat object as fill
|
| 58 |
+
When I assign <new-value> to fill.gradient_angle
|
| 59 |
+
Then fill.gradient_angle == <value>
|
| 60 |
+
|
| 61 |
+
Examples: angle value cases
|
| 62 |
+
| new-value | value |
|
| 63 |
+
| 42.42 | 42.42 |
|
| 64 |
+
| 270.0 | 270.0 |
|
| 65 |
+
| 480.0 | 120.0 |
|
| 66 |
+
| -90.0 | 270.0 |
|
| 67 |
+
| -942.4 | 137.6 |
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
Scenario: FillFormat.gradient_stops
|
| 71 |
+
Given a gradient FillFormat object as fill
|
| 72 |
+
Then fill.gradient_stops is a _GradientStops object
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
Scenario Outline: FillFormat.pattern getter
|
| 76 |
+
Given a FillFormat object as fill having <pattern> fill
|
| 77 |
+
Then fill.pattern is <value>
|
| 78 |
+
|
| 79 |
+
Examples: Pattern fill types
|
| 80 |
+
| pattern | value |
|
| 81 |
+
| no pattern | None |
|
| 82 |
+
| MSO_PATTERN.DIVOT | MSO_PATTERN.DIVOT |
|
| 83 |
+
| MSO_PATTERN.WAVE | MSO_PATTERN.WAVE |
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
Scenario: FillFormat.pattern setter
|
| 87 |
+
Given a FillFormat object as fill
|
| 88 |
+
When I call fill.patterned()
|
| 89 |
+
And I assign MSO_PATTERN.CROSS to fill.pattern
|
| 90 |
+
Then fill.pattern is MSO_PATTERN.CROSS
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
Scenario: _GradientStop.color
|
| 94 |
+
Given a _GradientStop object as stop
|
| 95 |
+
Then stop.color is a ColorFormat object
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
Scenario: _GradientStop.position getter
|
| 99 |
+
Given a _GradientStop object as stop
|
| 100 |
+
Then stop.position == 0.20
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
Scenario: _GradientStop.position setter
|
| 104 |
+
Given a _GradientStop object as stop
|
| 105 |
+
When I assign 0.42 to stop.position
|
| 106 |
+
Then stop.position == 0.42
|
tasks/tasksmith-74f059424102/tests/source/features/dml-line.feature
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Feature: Get and change line properties
|
| 2 |
+
In order to format a shape outline and other line elements
|
| 3 |
+
As a developer using python-pptx
|
| 4 |
+
I need a set of read/write line properties on line elements
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
Scenario: LineFormat.color
|
| 8 |
+
Given a LineFormat object as line
|
| 9 |
+
Then line.color is a ColorFormat object
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Scenario Outline: LineFormat.dash_style getter
|
| 13 |
+
Given a LineFormat object as line having <current> dash style
|
| 14 |
+
Then line.dash_style is <dash-style>
|
| 15 |
+
|
| 16 |
+
Examples: Line dash styles
|
| 17 |
+
| current | dash-style |
|
| 18 |
+
| no explicit | None |
|
| 19 |
+
| solid | MSO_LINE.SOLID |
|
| 20 |
+
| dashed | MSO_LINE.DASH |
|
| 21 |
+
| dash-dot | MSO_LINE.DASH_DOT |
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
Scenario Outline: LineFormat.width setter
|
| 25 |
+
Given a LineFormat object as line having <current> dash style
|
| 26 |
+
When I assign <dash-style> to line.dash_style
|
| 27 |
+
Then line.dash_style is <dash-style>
|
| 28 |
+
|
| 29 |
+
Examples: Line dash style assignment scenarios
|
| 30 |
+
| current | dash-style |
|
| 31 |
+
| no explicit | MSO_LINE.DASH |
|
| 32 |
+
| dashed | MSO_LINE.SOLID |
|
| 33 |
+
| solid | None |
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
Scenario: LineFormat.fill
|
| 37 |
+
Given a LineFormat object as line
|
| 38 |
+
Then line.fill is a FillFormat object
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
Scenario Outline: LineFormat.width getter
|
| 42 |
+
Given a LineFormat object as line having <line width> width
|
| 43 |
+
Then line.width is <reported line width>
|
| 44 |
+
|
| 45 |
+
Examples: Line widths
|
| 46 |
+
| line width | reported line width |
|
| 47 |
+
| no explicit | 0 |
|
| 48 |
+
| 1 pt | 1 pt |
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
Scenario Outline: LineFormat.width setter
|
| 52 |
+
Given a LineFormat object as line having <line width> width
|
| 53 |
+
When I assign <new line width> to line.width
|
| 54 |
+
Then line.width is <reported line width>
|
| 55 |
+
|
| 56 |
+
Examples: Line widths
|
| 57 |
+
| line width | new line width | reported line width |
|
| 58 |
+
| no explicit | None | 0 |
|
| 59 |
+
| no explicit | 1 pt | 1 pt |
|
| 60 |
+
| 1 pt | None | 0 |
|
| 61 |
+
| 1 pt | 1 pt | 1 pt |
|
| 62 |
+
| 1 pt | 2.34 pt | 2.34 pt |
|