mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
background logic
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user