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

Class _Run

src/pptx/text/text.py:635–681  ·  view source on GitHub ↗

Text run object. Corresponds to `a:r` child element in a paragraph.

Source from the content-addressed store, hash-verified

633
634
635class _Run(Subshape):
636 """Text run object. Corresponds to `a:r` child element in a paragraph."""
637
638 def __init__(self, r: CT_RegularTextRun, parent: ProvidesPart):
639 super(_Run, self).__init__(parent)
640 self._r = r
641
642 @property
643 def font(self):
644 """|Font| instance containing run-level character properties for the text in this run.
645
646 Character properties can be and perhaps most often are inherited from parent objects such
647 as the paragraph and slide layout the run is contained in. Only those specifically
648 overridden at the run level are contained in the font object.
649 """
650 rPr = self._r.get_or_add_rPr()
651 return Font(rPr)
652
653 @lazyproperty
654 def hyperlink(self) -> _Hyperlink:
655 """Proxy for any `a:hlinkClick` element under the run properties element.
656
657 Created on demand, the hyperlink object is available whether an `a:hlinkClick` element is
658 present or not, and creates or deletes that element as appropriate in response to actions
659 on its methods and attributes.
660 """
661 rPr = self._r.get_or_add_rPr()
662 return _Hyperlink(rPr, self)
663
664 @property
665 def text(self):
666 """Read/write. A unicode string containing the text in this run.
667
668 Assignment replaces all text in the run. The assigned value can be a 7-bit ASCII
669 string, a UTF-8 encoded 8-bit string, or unicode. String values are converted to
670 unicode assuming UTF-8 encoding.
671
672 Any other control characters in the assigned string other than tab or newline
673 are escaped as a hex representation. For example, ESC (ASCII 27) is escaped as
674 "_x001B_". Contrast the behavior of `TextFrame.text` and `_Paragraph.text` with
675 respect to line-feed and vertical-tab characters.
676 """
677 return self._r.text
678
679 @text.setter
680 def text(self, text: str):
681 self._r.text = text

Callers 6

font_fixtureMethod · 0.90
hyperlink_fixtureMethod · 0.90
text_get_fixtureMethod · 0.90
add_runMethod · 0.85
runsMethod · 0.85

Calls

no outgoing calls

Tested by 4

font_fixtureMethod · 0.72
hyperlink_fixtureMethod · 0.72
text_get_fixtureMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…