MCPcopy Create free account
hub / github.com/scanny/python-pptx / BaseShape

Class BaseShape

src/pptx/shapes/base.py:21–215  ·  view source on GitHub ↗

Base class for shape objects. Subclasses include |Shape|, |Picture|, and |GraphicFrame|.

Source from the content-addressed store, hash-verified

19
20
21class BaseShape(object):
22 """Base class for shape objects.
23
24 Subclasses include |Shape|, |Picture|, and |GraphicFrame|.
25 """
26
27 def __init__(self, shape_elm: ShapeElement, parent: ProvidesPart):
28 super().__init__()
29 self._element = shape_elm
30 self._parent = parent
31
32 def __eq__(self, other: object) -> bool:
33 """|True| if this shape object proxies the same element as *other*.
34
35 Equality for proxy objects is defined as referring to the same XML element, whether or not
36 they are the same proxy object instance.
37 """
38 if not isinstance(other, BaseShape):
39 return False
40 return self._element is other._element
41
42 def __ne__(self, other: object) -> bool:
43 if not isinstance(other, BaseShape):
44 return True
45 return self._element is not other._element
46
47 @lazyproperty
48 def click_action(self) -> ActionSetting:
49 """|ActionSetting| instance providing access to click behaviors.
50
51 Click behaviors are hyperlink-like behaviors including jumping to a hyperlink (web page)
52 or to another slide in the presentation. The click action is that defined on the overall
53 shape, not a run of text within the shape. An |ActionSetting| object is always returned,
54 even when no click behavior is defined on the shape.
55 """
56 cNvPr = self._element._nvXxPr.cNvPr # pyright: ignore[reportPrivateUsage]
57 return ActionSetting(cNvPr, self)
58
59 @property
60 def element(self) -> ShapeElement:
61 """`lxml` element for this shape, e.g. a CT_Shape instance.
62
63 Note that manipulating this element improperly can produce an invalid presentation file.
64 Make sure you know what you're doing if you use this to change the underlying XML.
65 """
66 return self._element
67
68 @property
69 def has_chart(self) -> bool:
70 """|True| if this shape is a graphic frame containing a chart object.
71
72 |False| otherwise. When |True|, the chart object can be accessed using the ``.chart``
73 property.
74 """
75 # This implementation is unconditionally False, the True version is
76 # on GraphicFrame subclass.
77 return False
78

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…