diff --git a/docs/examples/introduction/intro02.py b/docs/examples/introduction/intro02.py index 2f5d3ed64..514029ebb 100644 --- a/docs/examples/introduction/intro02.py +++ b/docs/examples/introduction/intro02.py @@ -22,6 +22,7 @@ class ExampleApp(App): def on_key(self, event): if event.key.isdigit(): self.styles.background = self.COLORS[int(event.key)] + self.refresh() self.bell() diff --git a/src/textual/app.py b/src/textual/app.py index fb9ef621d..fac988dc6 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -127,8 +127,8 @@ class App(Generic[ReturnType], DOMNode): CSS = """ App { - background: $surface; - color: $text-surface; + background: $background; + color: $text-background; } """ @@ -614,7 +614,7 @@ class App(Generic[ReturnType], DOMNode): self.screen.refresh(layout=True) def render(self) -> RenderableType: - return Blank() + return Blank(self.styles.background) def get_child(self, id: str) -> DOMNode: """Shorthand for self.screen.get_child(id: str) diff --git a/src/textual/renderables/blank.py b/src/textual/renderables/blank.py index c0ed42b2f..b83dbbc34 100644 --- a/src/textual/renderables/blank.py +++ b/src/textual/renderables/blank.py @@ -11,12 +11,8 @@ class Blank: """Draw solid background color.""" def __init__(self, color: Color | str = "transparent") -> None: - background = color if isinstance(color, Color) else Color.parse(color) - self._style = ( - Style() - if background.is_transparent - else Style.from_color(None, background.rich_color) - ) + background = Color.parse(color) + self._style = Style.from_color(bgcolor=background.rich_color) def __rich_console__( self, console: Console, options: ConsoleOptions diff --git a/src/textual/screen.py b/src/textual/screen.py index a8463446a..c960d33bd 100644 --- a/src/textual/screen.py +++ b/src/textual/screen.py @@ -33,8 +33,6 @@ class Screen(Widget): CSS = """ Screen { - background: $background; - color: $text-background; layout: vertical; overflow-y: auto; } @@ -71,7 +69,10 @@ class Screen(Widget): pass def render(self) -> RenderableType: - return Blank() + background = self.styles.background + if background.is_transparent: + return self.app.render() + return Blank(background) def get_offset(self, widget: Widget) -> Offset: """Get the absolute offset of a given Widget.