diff --git a/examples/mother.py b/examples/mother.py index fa28bfb35b..4fd0c3eda5 100644 --- a/examples/mother.py +++ b/examples/mother.py @@ -83,11 +83,13 @@ async def on_input(self, event: Input.Submitted) -> None: await chat_view.mount(Prompt(event.value)) await chat_view.mount(response := Response()) response.anchor() + self.send_prompt(event.value, response) @work(thread=True) def send_prompt(self, prompt: str, response: Response) -> None: """Get the response in a thread.""" + response_content = "" llm_response = self.model.prompt(prompt, system=SYSTEM) for chunk in llm_response: diff --git a/src/textual/css/_style_properties.py b/src/textual/css/_style_properties.py index bbfcec7c87..f4fc9199b2 100644 --- a/src/textual/css/_style_properties.py +++ b/src/textual/css/_style_properties.py @@ -745,10 +745,10 @@ def __set__( _rich_traceback_omit = True if offset is None: if obj.clear_rule(self.name): - obj.refresh(layout=True) + obj.refresh(layout=True, repaint=False) elif isinstance(offset, ScalarOffset): if obj.set_rule(self.name, offset): - obj.refresh(layout=True) + obj.refresh(layout=True, repaint=False) else: x, y = offset @@ -771,7 +771,7 @@ def __set__( _offset = ScalarOffset(scalar_x, scalar_y) if obj.set_rule(self.name, _offset): - obj.refresh(layout=True) + obj.refresh(layout=True, repaint=False) class StringEnumProperty(Generic[EnumType]): diff --git a/src/textual/css/styles.py b/src/textual/css/styles.py index 668042a592..fd6fe43c2d 100644 --- a/src/textual/css/styles.py +++ b/src/textual/css/styles.py @@ -238,9 +238,7 @@ class StylesBase: node: DOMNode | None = None - display = StringEnumProperty( - VALID_DISPLAY, "block", layout=True, refresh_parent=True, refresh_children=True - ) + display = StringEnumProperty(VALID_DISPLAY, "block", layout=True) """Set the display of the widget, defining how it's rendered. Valid values are "block" or "none". @@ -253,9 +251,7 @@ class StylesBase: StyleValueError: If an invalid display is specified. """ - visibility = StringEnumProperty( - VALID_VISIBILITY, "visible", layout=True, refresh_parent=True - ) + visibility = StringEnumProperty(VALID_VISIBILITY, "visible", layout=True) """Set the visibility of the widget. Valid values are "visible" or "hidden". @@ -281,6 +277,7 @@ class StylesBase: """ auto_color = BooleanProperty(default=False) + """Enable automatic picking of best contrasting color.""" color = ColorProperty(Color(255, 255, 255)) """Set the foreground (text) color of the widget. Supports `Color` objects but also strings e.g. "red" or "#ff0000". @@ -326,7 +323,9 @@ class StylesBase: """Set the left border of the widget e.g. ("rounded", "green") or "none".""" border_title_align = StringEnumProperty(VALID_ALIGN_HORIZONTAL, "left") + """The alignment of the border title text.""" border_subtitle_align = StringEnumProperty(VALID_ALIGN_HORIZONTAL, "right") + """The alignment of the border subtitle text.""" outline = BorderProperty(layout=False) """Set the outline of the widget e.g. ("rounded", "green") or "none". @@ -342,8 +341,10 @@ class StylesBase: """Set the left outline of the widget e.g. ("rounded", "green") or "none".""" keyline = KeylineProperty() + """Keyline parameters.""" box_sizing = StringEnumProperty(VALID_BOX_SIZING, "border-box", layout=True) + """Box sizing method ("border-box" or "conetnt-box")""" width = ScalarProperty(percent_unit=Unit.WIDTH) """Set the width of the widget.""" height = ScalarProperty(percent_unit=Unit.HEIGHT) @@ -632,7 +633,12 @@ def get_rule(self, rule_name: str, default: object = None) -> object: raise NotImplementedError() def refresh( - self, *, layout: bool = False, children: bool = False, parent: bool = False + self, + *, + layout: bool = False, + children: bool = False, + parent: bool = False, + repaint: bool = True, ) -> None: """Mark the styles as requiring a refresh. @@ -640,6 +646,7 @@ def refresh( layout: Also require a layout. children: Also refresh children. parent: Also refresh the parent. + repaint: Repaint the widgets. """ def reset(self) -> None: @@ -850,17 +857,22 @@ def set_rule(self, rule: str, value: object | None) -> bool: return changed def refresh( - self, *, layout: bool = False, children: bool = False, parent: bool = False + self, + *, + layout: bool = False, + children: bool = False, + parent: bool = False, + repaint=True, ) -> None: node = self.node if node is None or not node._is_mounted: return if parent and node._parent is not None: - node._parent.refresh() + node._parent.refresh(repaint=repaint) node.refresh(layout=layout) if children: for child in node.walk_children(with_self=False, reverse=True): - child.refresh(layout=layout) + child.refresh(layout=layout, repaint=repaint) def reset(self) -> None: """Reset the rules to initial state.""" @@ -1334,9 +1346,16 @@ def __rich_repr__(self) -> rich.repr.Result: yield rule_name, getattr(self, rule_name) def refresh( - self, *, layout: bool = False, children: bool = False, parent: bool = False + self, + *, + layout: bool = False, + children: bool = False, + parent: bool = False, + repaint: bool = True, ) -> None: - self._inline_styles.refresh(layout=layout, children=children, parent=parent) + self._inline_styles.refresh( + layout=layout, children=children, parent=parent, repaint=repaint + ) def merge(self, other: StylesBase) -> None: """Merge values from another Styles.