diff --git a/docs/events/print.md b/docs/events/print.md index 2d836f0e82..942ccbf5ea 100644 --- a/docs/events/print.md +++ b/docs/events/print.md @@ -1,14 +1,3 @@ -# Print - -The `Print` event is sent to a widget that is capturing prints. - -## Attributes - -| Attribute | Type | Purpose | -|-----------|--------|-----------------------------------------------------| -| `text` | `str` | The text that was printed. | -| `stderr` | `bool` | `True` if printed to `stderr`, `False` if `stdout`. | - -## Code - ::: textual.events.Print + options: + heading_level: 1 diff --git a/src/textual/events.py b/src/textual/events.py index 52d2401ae7..9059c3fec0 100644 --- a/src/textual/events.py +++ b/src/textual/events.py @@ -660,21 +660,26 @@ class ScreenSuspend(Event, bubble=False): @rich.repr.auto class Print(Event, bubble=False): - """Sent to a widget that is capturing prints. + """Sent to a widget that is capturing [`print`][print]. - [ ] Bubbles - [ ] Verbose Args: text: Text that was printed. - stderr: True if the print was to stderr, or False for stdout. + stderr: `True` if the print was to stderr, or `False` for stdout. + Note: + Python's [`print`][print] output can be captured with + [`App.begin_capture_print`][textual.app.App.begin_capture_print]. """ def __init__(self, text: str, stderr: bool = False) -> None: super().__init__() self.text = text + """The text that was printed.""" self.stderr = stderr + """`True` if the print was to stderr, or `False` for stdout.""" def __rich_repr__(self) -> rich.repr.Result: yield self.text