Construct a text instance by combining a sequence of strings with optional styles. The positional arguments should be either strings, or a tuple of string + style. Args: style (Union[str, Style], optional): Base style for text. Defaults to "". justify (str, o
(
cls,
*parts: Union[str, "Text", Tuple[str, StyleType]],
style: Union[str, Style] = "",
justify: Optional["JustifyMethod"] = None,
overflow: Optional["OverflowMethod"] = None,
no_wrap: Optional[bool] = None,
end: str = "\n",
tab_size: int = 8,
meta: Optional[Dict[str, Any]] = None,
)
| 355 | |
| 356 | @classmethod |
| 357 | def assemble( |
| 358 | cls, |
| 359 | *parts: Union[str, "Text", Tuple[str, StyleType]], |
| 360 | style: Union[str, Style] = "", |
| 361 | justify: Optional["JustifyMethod"] = None, |
| 362 | overflow: Optional["OverflowMethod"] = None, |
| 363 | no_wrap: Optional[bool] = None, |
| 364 | end: str = "\n", |
| 365 | tab_size: int = 8, |
| 366 | meta: Optional[Dict[str, Any]] = None, |
| 367 | ) -> "Text": |
| 368 | """Construct a text instance by combining a sequence of strings with optional styles. |
| 369 | The positional arguments should be either strings, or a tuple of string + style. |
| 370 | |
| 371 | Args: |
| 372 | style (Union[str, Style], optional): Base style for text. Defaults to "". |
| 373 | justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. |
| 374 | overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. |
| 375 | no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None. |
| 376 | end (str, optional): Character to end text with. Defaults to "\\\\n". |
| 377 | tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None. |
| 378 | meta (Dict[str, Any], optional). Meta data to apply to text, or None for no meta data. Default to None |
| 379 | |
| 380 | Returns: |
| 381 | Text: A new text instance. |
| 382 | """ |
| 383 | text = cls( |
| 384 | style=style, |
| 385 | justify=justify, |
| 386 | overflow=overflow, |
| 387 | no_wrap=no_wrap, |
| 388 | end=end, |
| 389 | tab_size=tab_size, |
| 390 | ) |
| 391 | append = text.append |
| 392 | _Text = Text |
| 393 | for part in parts: |
| 394 | if isinstance(part, (_Text, str)): |
| 395 | append(part) |
| 396 | else: |
| 397 | append(*part) |
| 398 | if meta: |
| 399 | text.apply_meta(meta) |
| 400 | return text |
| 401 | |
| 402 | @property |
| 403 | def plain(self) -> str: |