diff --git a/src/textual/app.py b/src/textual/app.py index a5dba1e2cf..637a049af1 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -1661,6 +1661,11 @@ async def _on_css_change(self) -> None: self.stylesheet.update(screen) def render(self) -> RenderResult: + """Render method inherited from widget, to render the screen's background. + + May be override to customize background visuals. + + """ return Blank(self.styles.background) ExpectType = TypeVar("ExpectType", bound=Widget) diff --git a/src/textual/screen.py b/src/textual/screen.py index c4696d3357..b84fbc277a 100644 --- a/src/textual/screen.py +++ b/src/textual/screen.py @@ -265,6 +265,11 @@ def layers(self) -> tuple[str, ...]: return (*super().layers, *extras) def render(self) -> RenderableType: + """Render method inherited from widget, used to render the screen's background. + + Returns: + Background renderable. + """ background = self.styles.background try: base_screen = visible_screen_stack.get().pop() @@ -272,10 +277,13 @@ def render(self) -> RenderableType: base_screen = None if base_screen is not None and background.a < 1: + # If background is translucent, render a background screen return BackgroundScreen(base_screen, background) if background.is_transparent: + # If the background is transparent, defer to App.render return self.app.render() + # Render a screen of a solid color. return Blank(background) def get_offset(self, widget: Widget) -> Offset: