Skip to content

Commit

Permalink
Tidy the documentation for the Print event
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Mar 20, 2024
1 parent d061d6f commit e2df78c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
15 changes: 2 additions & 13 deletions docs/events/print.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions src/textual/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e2df78c

Please sign in to comment.