mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Fix variables in Screens, remove dark reactive from Screen
This commit is contained in:
@@ -16,15 +16,36 @@ class CustomScreen(Screen):
|
||||
yield Focusable(f"Screen {id(self)} - three")
|
||||
yield Focusable(f"Screen {id(self)} - four")
|
||||
yield Input(placeholder="Text input")
|
||||
# yield Footer()
|
||||
yield Footer()
|
||||
|
||||
|
||||
class MyInstalledScreen(Screen):
|
||||
def __init__(self, string: str):
|
||||
super().__init__()
|
||||
self.string = string
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Static(f"Hello, world! {self.string}")
|
||||
|
||||
|
||||
class ScreensFocusApp(App):
|
||||
BINDINGS = [
|
||||
Binding("plus", "push_new_screen", "Push"),
|
||||
Binding("minus", "pop_top_screen", "Pop"),
|
||||
Binding("d", "toggle_dark", "Toggle Dark"),
|
||||
Binding("q", "push_screen('q')", "Screen Q"),
|
||||
Binding("w", "push_screen('w')", "Screen W"),
|
||||
Binding("e", "push_screen('e')", "Screen E"),
|
||||
Binding("r", "push_screen('r')", "Screen R"),
|
||||
]
|
||||
|
||||
SCREENS = {
|
||||
"q": MyInstalledScreen("q"),
|
||||
"w": MyInstalledScreen("w"),
|
||||
"e": MyInstalledScreen("e"),
|
||||
"r": MyInstalledScreen("r"),
|
||||
}
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Focusable("App - one")
|
||||
yield Input(placeholder="Text input")
|
||||
@@ -32,7 +53,7 @@ class ScreensFocusApp(App):
|
||||
yield Focusable("App - two")
|
||||
yield Focusable("App - three")
|
||||
yield Focusable("App - four")
|
||||
# yield Footer()
|
||||
yield Footer()
|
||||
|
||||
def action_push_new_screen(self):
|
||||
self.push_screen(CustomScreen())
|
||||
@@ -43,6 +64,9 @@ class ScreensFocusApp(App):
|
||||
except ScreenStackError:
|
||||
pass
|
||||
|
||||
def _action_toggle_dark(self):
|
||||
self.dark = not self.dark
|
||||
|
||||
|
||||
app = ScreensFocusApp(css_path="screens_focus.css")
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -353,8 +353,6 @@ class App(Generic[ReturnType], DOMNode):
|
||||
|
||||
def watch_dark(self, dark: bool) -> None:
|
||||
"""Watches the dark bool."""
|
||||
|
||||
self.screen.dark = dark
|
||||
self.set_class(dark, "-dark-mode")
|
||||
self.set_class(not dark, "-light-mode")
|
||||
self.refresh_css()
|
||||
|
||||
@@ -192,7 +192,7 @@ class Stylesheet:
|
||||
variables (dict[str, str]): A mapping of name to variable.
|
||||
"""
|
||||
self._variables = variables
|
||||
self._variables_tokens = None
|
||||
self.__variable_tokens = None
|
||||
|
||||
def _parse_rules(
|
||||
self,
|
||||
|
||||
@@ -38,7 +38,6 @@ class Screen(Widget):
|
||||
}
|
||||
"""
|
||||
|
||||
dark: Reactive[bool] = Reactive(False)
|
||||
focused: Reactive[Widget | None] = Reactive(None)
|
||||
|
||||
def __init__(
|
||||
|
||||
Reference in New Issue
Block a user