Append text or content to this content. Note this is a little inefficient, if you have many strings to append, consider [`join`][textual.content.Content.join]. Args: content: A content instance, or a string. Returns: New content.
(self, content: Content | str)
| 893 | return spans |
| 894 | |
| 895 | def append(self, content: Content | str) -> Content: |
| 896 | """Append text or content to this content. |
| 897 | |
| 898 | Note this is a little inefficient, if you have many strings to append, consider [`join`][textual.content.Content.join]. |
| 899 | |
| 900 | Args: |
| 901 | content: A content instance, or a string. |
| 902 | |
| 903 | Returns: |
| 904 | New content. |
| 905 | """ |
| 906 | if isinstance(content, str): |
| 907 | return Content( |
| 908 | f"{self.plain}{content}", |
| 909 | self._spans, |
| 910 | ( |
| 911 | None |
| 912 | if self._cell_length is None |
| 913 | else self._cell_length + cell_len(content) |
| 914 | ), |
| 915 | strip_control_codes=False, |
| 916 | ) |
| 917 | return EMPTY_CONTENT.join([self, content]) |
| 918 | |
| 919 | def append_text(self, text: str, style: Style | str = "") -> Content: |
| 920 | """Append text give as a string, with an optional style. |