Skip to content

Commit f419505

Browse files
feat: update DemoApp to use external CSS file for demonstration
1 parent 9b40454 commit f419505

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

examples/textual/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ textual-hmr main:DemoApp
1212

1313
## What to Observe
1414

15-
The app renders a short message from `message.py`.
15+
The app renders a short message from `message.py` and loads styles from `main.tcss`.
1616

1717
- Change the string in `message.py` and save it.
1818
- The current Textual app instance will exit and restart in-process.
1919
- The updated message will appear immediately after restart.
20+
- Change `main.tcss` and save it.
21+
- Textual will hot-refresh the stylesheet without restarting the Python app.
2022

21-
Because `DemoApp` is exported as an `App` subclass, `textual-hmr` also enables Textual's built-in CSS watching by default. You can tweak the inline CSS in `main.py` to compare Python-level restarts with CSS-only refreshes.
23+
Because `DemoApp` is exported as an `App` subclass, `textual-hmr` also enables Textual's built-in CSS watching by default. This example lets you compare Python-level restarts with TCSS-only refreshes side by side.

examples/textual/main.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66

77
class DemoApp(App[None]):
8-
CSS = """
9-
Screen { align: center middle; }
10-
#panel { width: 56; padding: 1 3; border: round $accent; background: $surface; }
11-
"""
8+
CSS_PATH = "main.tcss"
129

1310
def compose(self):
1411
yield Header()

examples/textual/main.tcss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Screen {
2+
align: center middle;
3+
}
4+
5+
#panel {
6+
width: 56;
7+
padding: 1 3;
8+
border: round $accent;
9+
background: $surface;
10+
}

0 commit comments

Comments
 (0)