Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/examples/guide/screens/screen01.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from textual.app import App, Screen, ComposeResult
from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widgets import Static


Expand Down
3 changes: 2 additions & 1 deletion docs/examples/guide/screens/screen02.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from textual.app import App, Screen, ComposeResult
from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widgets import Static


Expand Down
18 changes: 9 additions & 9 deletions docs/guide/screens.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Textual requires that there be at least one screen object and will create one im

!!! tip

Try printing `widget.parent` to see what object your widget is connected to.
Try printing `widget.parent` to see what object your widget is connected to.

<div class="excalidraw">
--8<-- "docs/images/dom1.excalidraw.svg"
Expand All @@ -24,13 +24,13 @@ Let's look at a simple example of writing a screen class to simulate Window's [b

=== "screen01.py"

```python title="screen01.py" hl_lines="17-23 28"
```python title="screen01.py" hl_lines="18-24 29"
--8<-- "docs/examples/guide/screens/screen01.py"
```

=== "screen01.css"

```sass title="screen01.css"
```sass title="screen01.css"
--8<-- "docs/examples/guide/screens/screen01.css"
```

Expand All @@ -53,13 +53,13 @@ You can also _install_ new named screens dynamically with the [install_screen][t

=== "screen02.py"

```python title="screen02.py" hl_lines="30-31"
```python title="screen02.py" hl_lines="31-32"
--8<-- "docs/examples/guide/screens/screen02.py"
```

=== "screen02.css"

```sass title="screen02.css"
```sass title="screen02.css"
--8<-- "docs/examples/guide/screens/screen02.css"
```

Expand Down Expand Up @@ -96,7 +96,7 @@ You can also push screens with the `"app.push_screen"` action, which requires th

### Pop screen

The [pop_screen][textual.app.App.pop_screen] method removes the top-most screen from the stack, and makes the new top screen active.
The [pop_screen][textual.app.App.pop_screen] method removes the top-most screen from the stack, and makes the new top screen active.

!!! note

Expand All @@ -115,7 +115,7 @@ You can also pop screens with the `"app.pop_screen"` action.

### Switch screen

The [switch_screen][textual.app.App.switch_screen] method replaces the top of the stack with a new screen.
The [switch_screen][textual.app.App.switch_screen] method replaces the top of the stack with a new screen.

<div class="excalidraw">
--8<-- "docs/images/screens/switch_screen.excalidraw.svg"
Expand All @@ -139,13 +139,13 @@ Screens can be used to implement modal dialogs. The following example pushes a s

=== "modal01.css"

```sass title="modal01.css"
```sass title="modal01.css"
--8<-- "docs/examples/guide/screens/modal01.css"
```

=== "Output"

```{.textual path="docs/examples/guide/screens/modal01.py" press="q,_"}
```

Note the `request_quit` action in the app which pushes a new instance of `QuitScreen`. This makes the quit screen active. if you click cancel, the quit screen calls `pop_screen` to return the default screen. This also removes and deletes the `QuitScreen` object.