mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
debugging app refreshes
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -498,7 +498,7 @@ class Compositor:
|
||||
"""Get rendered widgets (lists of segments) in the composition.
|
||||
|
||||
Returns:
|
||||
Iterable[tuple[Region, Region, Lines]]: An interable of <region>, <clip region>, and <lines>
|
||||
Iterable[tuple[Region, Region, Lines]]: An iterable of <region>, <clip region>, and <lines>
|
||||
"""
|
||||
# If a renderable throws an error while rendering, the user likely doesn't care about the traceback
|
||||
# up to this point.
|
||||
|
||||
@@ -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>", 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> {action_name!r} has no target")
|
||||
if callable(method):
|
||||
await invoke(method, *params)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -31,8 +31,10 @@ class Screen(Widget):
|
||||
Screen {
|
||||
layout: vertical;
|
||||
overflow-y: auto;
|
||||
/*
|
||||
background: $surface;
|
||||
color: $text-surface;
|
||||
*/
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user