Skip to content

Commit 8fc2bd1

Browse files
committed
Basic CSS for counter example
1 parent 0fb0e2b commit 8fc2bd1

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

docs/examples/guide/widgets/bindings.py renamed to docs/examples/guide/widgets/calculator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
from textual.app import App, ComposeResult
22
from textual.binding import Binding
33
from textual.reactive import reactive
4-
from textual.widgets import Static
4+
from textual.widgets import Footer, Static
55

66

77
class Counter(Static, can_focus=True):
88
"""A counter that can be incremented and decremented by pressing keys."""
99

1010
BINDINGS = [
11-
Binding("up", "change_count(1)", "Increment"),
12-
Binding("down", "change_count(-1)", "Decrement"),
11+
Binding("up,k", "change_count(1)", "Increment"),
12+
Binding("down,j", "change_count(-1)", "Decrement"),
1313
]
1414

1515
count = reactive(0)
@@ -22,9 +22,12 @@ def action_change_count(self, amount: int) -> None:
2222

2323

2424
class CalculatorApp(App[None]):
25+
CSS_PATH = "calculator.tcss"
26+
2527
def compose(self) -> ComposeResult:
2628
yield Counter()
2729
yield Counter()
30+
yield Footer()
2831

2932

3033
if __name__ == "__main__":
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Counter {
2+
background: $panel-darken-1;
3+
padding: 1 2;
4+
color: $text-muted;
5+
6+
&:focus {
7+
background: $primary;
8+
color: $text;
9+
text-style: bold;
10+
outline-left: thick $accent;
11+
}
12+
}

0 commit comments

Comments
 (0)