diff --git a/docs/examples/introduction/intro02.py b/docs/examples/introduction/intro02.py index 2f5d3ed64..cde514be6 100644 --- a/docs/examples/introduction/intro02.py +++ b/docs/examples/introduction/intro02.py @@ -3,6 +3,10 @@ from textual.app import App class ExampleApp(App): + CSS = """ + + """ + COLORS = [ "white", "maroon", @@ -18,12 +22,15 @@ class ExampleApp(App): def on_mount(self): self.styles.background = "darkblue" + self.bind("t", "tree") def on_key(self, event): if event.key.isdigit(): self.styles.background = self.COLORS[int(event.key)] self.bell() + def action_tree(self): + self.log(self.tree) app = ExampleApp() app.run() diff --git a/src/textual/_compositor.py b/src/textual/_compositor.py index ba2f30f29..6b6848c5f 100644 --- a/src/textual/_compositor.py +++ b/src/textual/_compositor.py @@ -498,7 +498,7 @@ class Compositor: """Get rendered widgets (lists of segments) in the composition. Returns: - Iterable[tuple[Region, Region, Lines]]: An interable of , , and + Iterable[tuple[Region, Region, Lines]]: An iterable of , , and """ # If a renderable throws an error while rendering, the user likely doesn't care about the traceback # up to this point. diff --git a/src/textual/app.py b/src/textual/app.py index 366d733f0..88db0ec06 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -526,7 +526,7 @@ class App(Generic[ReturnType], DOMNode): self.screen.refresh(layout=True) def render(self) -> RenderableType: - return "" + return Blank("red") def query(self, selector: str | None = None) -> DOMQuery: """Get a DOM query in the current screen. @@ -999,7 +999,6 @@ class App(Generic[ReturnType], DOMNode): action_target = default_namespace or self action_name = target - log("", action) await self.dispatch_action(action_target, action_name, params) async def dispatch_action( @@ -1014,6 +1013,8 @@ class App(Generic[ReturnType], DOMNode): _rich_traceback_guard = True method_name = f"action_{action_name}" method = getattr(namespace, method_name, None) + if method is None: + log(f" {action_name!r} has no target") if callable(method): await invoke(method, *params) diff --git a/src/textual/css/styles.py b/src/textual/css/styles.py index ae3e7f5a1..7a079fb3b 100644 --- a/src/textual/css/styles.py +++ b/src/textual/css/styles.py @@ -476,6 +476,7 @@ class Styles(StylesBase): return self._rules.get(rule, default) def refresh(self, *, layout: bool = False) -> None: + print(self, self.node, "REFRESH", layout) if self.node is not None: self.node.refresh(layout=layout) diff --git a/src/textual/renderables/blank.py b/src/textual/renderables/blank.py index a0df77ed1..9dd07b7d9 100644 --- a/src/textual/renderables/blank.py +++ b/src/textual/renderables/blank.py @@ -24,7 +24,7 @@ class Blank: width = options.max_width height = options.height or options.max_height - segment = Segment(f"{' ' * width}", style=self._style) + segment = Segment(" " * width, self._style) line = Segment.line() for _ in range(height): yield segment diff --git a/src/textual/screen.py b/src/textual/screen.py index 12b8565e8..b24a6405e 100644 --- a/src/textual/screen.py +++ b/src/textual/screen.py @@ -31,8 +31,10 @@ class Screen(Widget): Screen { layout: vertical; overflow-y: auto; + /* background: $surface; color: $text-surface; + */ } """