MCPcopy Index your code
hub / github.com/python-openxml/python-docx / CT_Picture

Class CT_Picture

src/docx/oxml/shape.py:135–179  ·  view source on GitHub ↗

`` `` element, a DrawingML picture.

Source from the content-addressed store, hash-verified

133
134
135class CT_Picture(BaseOxmlElement):
136 """``<pic:pic>`` element, a DrawingML picture."""
137
138 nvPicPr: CT_PictureNonVisual = OneAndOnlyOne( # pyright: ignore[reportAssignmentType]
139 "pic:nvPicPr"
140 )
141 blipFill: CT_BlipFillProperties = OneAndOnlyOne( # pyright: ignore[reportAssignmentType]
142 "pic:blipFill"
143 )
144 spPr: CT_ShapeProperties = OneAndOnlyOne("pic:spPr") # pyright: ignore[reportAssignmentType]
145
146 @classmethod
147 def new(cls, pic_id: int, filename: str, rId: str, cx: Length, cy: Length) -> CT_Picture:
148 """A new minimum viable `<pic:pic>` (picture) element."""
149 pic = parse_xml(cls._pic_xml())
150 pic.nvPicPr.cNvPr.id = pic_id
151 pic.nvPicPr.cNvPr.name = filename
152 pic.blipFill.blip.embed = rId
153 pic.spPr.cx = cx
154 pic.spPr.cy = cy
155 return pic
156
157 @classmethod
158 def _pic_xml(cls):
159 return (
160 "<pic:pic %s>\n"
161 " <pic:nvPicPr>\n"
162 ' <pic:cNvPr id="666" name="unnamed"/>\n'
163 " <pic:cNvPicPr/>\n"
164 " </pic:nvPicPr>\n"
165 " <pic:blipFill>\n"
166 " <a:blip/>\n"
167 " <a:stretch>\n"
168 " <a:fillRect/>\n"
169 " </a:stretch>\n"
170 " </pic:blipFill>\n"
171 " <pic:spPr>\n"
172 " <a:xfrm>\n"
173 ' <a:off x="0" y="0"/>\n'
174 ' <a:ext cx="914400" cy="914400"/>\n'
175 " </a:xfrm>\n"
176 ' <a:prstGeom prst="rect"/>\n'
177 " </pic:spPr>\n"
178 "</pic:pic>" % nsdecls("pic", "a", "r")
179 )
180
181
182class CT_PictureNonVisual(BaseOxmlElement):

Callers

nothing calls this directly

Calls 1

OneAndOnlyOneClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…