-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:Textualize/textual into themes
- Loading branch information
Showing
17 changed files
with
1,187 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Counter { | ||
background: $panel-darken-1; | ||
padding: 1 2; | ||
color: $text-muted; | ||
|
||
&:focus { /* (1)! */ | ||
background: $primary; | ||
color: $text; | ||
text-style: bold; | ||
outline-left: thick $accent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from textual.app import App, ComposeResult, RenderResult | ||
from textual.reactive import reactive | ||
from textual.widgets import Footer, Static | ||
|
||
|
||
class Counter(Static, can_focus=True): # (1)! | ||
"""A counter that can be incremented and decremented by pressing keys.""" | ||
|
||
count = reactive(0) | ||
|
||
def render(self) -> RenderResult: | ||
return f"Count: {self.count}" | ||
|
||
|
||
class CounterApp(App[None]): | ||
CSS_PATH = "counter.tcss" | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Counter() | ||
yield Counter() | ||
yield Counter() | ||
yield Footer() | ||
|
||
|
||
if __name__ == "__main__": | ||
app = CounterApp() | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from textual.app import App, ComposeResult, RenderResult | ||
from textual.reactive import reactive | ||
from textual.widgets import Footer, Static | ||
|
||
|
||
class Counter(Static, can_focus=True): | ||
"""A counter that can be incremented and decremented by pressing keys.""" | ||
|
||
BINDINGS = [ | ||
("up,k", "change_count(1)", "Increment"), # (1)! | ||
("down,j", "change_count(-1)", "Decrement"), | ||
] | ||
|
||
count = reactive(0) | ||
|
||
def render(self) -> RenderResult: | ||
return f"Count: {self.count}" | ||
|
||
def action_change_count(self, amount: int) -> None: # (2)! | ||
self.count += amount | ||
|
||
|
||
class CounterApp(App[None]): | ||
CSS_PATH = "counter.tcss" | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Counter() | ||
yield Counter() | ||
yield Counter() | ||
yield Footer() | ||
|
||
|
||
if __name__ == "__main__": | ||
app = CounterApp() | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.