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

Class _Paragraph

src/pptx/text/text.py:467–632  ·  view source on GitHub ↗

Paragraph object. Not intended to be constructed directly.

Source from the content-addressed store, hash-verified

465
466
467class _Paragraph(Subshape):
468 """Paragraph object. Not intended to be constructed directly."""
469
470 def __init__(self, p: CT_TextParagraph, parent: ProvidesPart):
471 super(_Paragraph, self).__init__(parent)
472 self._element = self._p = p
473
474 def add_line_break(self):
475 """Add line break at end of this paragraph."""
476 self._p.add_br()
477
478 def add_run(self) -> _Run:
479 """Return a new run appended to the runs in this paragraph."""
480 r = self._p.add_r()
481 return _Run(r, self)
482
483 @property
484 def alignment(self) -> PP_PARAGRAPH_ALIGNMENT | None:
485 """Horizontal alignment of this paragraph.
486
487 The value |None| indicates the paragraph should 'inherit' its effective value from its
488 style hierarchy. Assigning |None| removes any explicit setting, causing its inherited
489 value to be used.
490 """
491 return self._pPr.algn
492
493 @alignment.setter
494 def alignment(self, value: PP_PARAGRAPH_ALIGNMENT | None):
495 self._pPr.algn = value
496
497 def clear(self):
498 """Remove all content from this paragraph.
499
500 Paragraph properties are preserved. Content includes runs, line breaks, and fields.
501 """
502 for elm in self._element.content_children:
503 self._element.remove(elm)
504 return self
505
506 @property
507 def font(self) -> Font:
508 """|Font| object containing default character properties for the runs in this paragraph.
509
510 These character properties override default properties inherited from parent objects such
511 as the text frame the paragraph is contained in and they may be overridden by character
512 properties set at the run level.
513 """
514 return Font(self._defRPr)
515
516 @property
517 def level(self) -> int:
518 """Indentation level of this paragraph.
519
520 Read-write. Integer in range 0..8 inclusive. 0 represents a top-level paragraph and is the
521 default value. Indentation level is most commonly encountered in a bulleted list, as is
522 found on a word bullet slide.
523 """
524 return self._pPr.lvl

Callers 15

after_get_fixtureMethod · 0.90
after_set_fixtureMethod · 0.90
alignment_get_fixtureMethod · 0.90
alignment_set_fixtureMethod · 0.90
before_get_fixtureMethod · 0.90
before_set_fixtureMethod · 0.90
clear_fixtureMethod · 0.90
level_get_fixtureMethod · 0.90
level_set_fixtureMethod · 0.90
line_break_fixtureMethod · 0.90

Calls

no outgoing calls

Tested by 15

after_get_fixtureMethod · 0.72
after_set_fixtureMethod · 0.72
alignment_get_fixtureMethod · 0.72
alignment_set_fixtureMethod · 0.72
before_get_fixtureMethod · 0.72
before_set_fixtureMethod · 0.72
clear_fixtureMethod · 0.72
level_get_fixtureMethod · 0.72
level_set_fixtureMethod · 0.72
line_break_fixtureMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…