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

Class InlineShape

src/docx/shape.py:51–103  ·  view source on GitHub ↗

Proxy for an `` `` element, representing the container for an inline graphical object.

Source from the content-addressed store, hash-verified

49
50
51class InlineShape:
52 """Proxy for an ``<wp:inline>`` element, representing the container for an inline
53 graphical object."""
54
55 def __init__(self, inline: CT_Inline):
56 super(InlineShape, self).__init__()
57 self._inline = inline
58
59 @property
60 def height(self) -> Length:
61 """Read/write.
62
63 The display height of this inline shape as an |Emu| instance.
64 """
65 return self._inline.extent.cy
66
67 @height.setter
68 def height(self, cy: Length):
69 self._inline.extent.cy = cy
70 self._inline.graphic.graphicData.pic.spPr.cy = cy
71
72 @property
73 def type(self):
74 """The type of this inline shape as a member of
75 ``docx.enum.shape.WD_INLINE_SHAPE``, e.g. ``LINKED_PICTURE``.
76
77 Read-only.
78 """
79 graphicData = self._inline.graphic.graphicData
80 uri = graphicData.uri
81 if uri == nsmap["pic"]:
82 blip = graphicData.pic.blipFill.blip
83 if blip.link is not None:
84 return WD_INLINE_SHAPE.LINKED_PICTURE
85 return WD_INLINE_SHAPE.PICTURE
86 if uri == nsmap["c"]:
87 return WD_INLINE_SHAPE.CHART
88 if uri == nsmap["dgm"]:
89 return WD_INLINE_SHAPE.SMART_ART
90 return WD_INLINE_SHAPE.NOT_IMPLEMENTED
91
92 @property
93 def width(self):
94 """Read/write.
95
96 The display width of this inline shape as an |Emu| instance.
97 """
98 return self._inline.extent.cx
99
100 @width.setter
101 def width(self, cx: Length):
102 self._inline.extent.cx = cx
103 self._inline.graphic.graphicData.pic.spPr.cx = cx

Callers 6

add_pictureMethod · 0.90
__getitem__Method · 0.85
__iter__Method · 0.85

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…