From 14e87b6c99b518e43c64ba63de5485e7bb7aaac2 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Tue, 4 Oct 2022 10:12:25 +0100 Subject: [PATCH] shrink expand --- examples/code_browser.css | 3 ++- src/textual/widget.py | 4 ++-- src/textual/widgets/_static.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/code_browser.css b/examples/code_browser.css index a95c820fb..2a58b68e1 100644 --- a/examples/code_browser.css +++ b/examples/code_browser.css @@ -21,7 +21,8 @@ DirectoryTree { } #code-view { - overflow: auto scroll; + overflow: auto scroll; + min-width: 100%; } #code { width: auto; diff --git a/src/textual/widget.py b/src/textual/widget.py index 9102784c2..4dd7089d6 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -407,9 +407,9 @@ class Widget(DOMNode): renderable = self._render() width = measure(console, renderable, container.width) - if not self.expand: + if self.expand: width = max(container.width, width) - if not self.shrink: + if self.shrink: width = min(width, container.width) self._content_width_cache = (cache_key, width) diff --git a/src/textual/widgets/_static.py b/src/textual/widgets/_static.py index bbf50dfee..91ef56119 100644 --- a/src/textual/widgets/_static.py +++ b/src/textual/widgets/_static.py @@ -30,8 +30,8 @@ class Static(Widget): Args: renderable (RenderableType, optional): A Rich renderable, or string containing console markup. Defaults to "". - expand (bool, optional): Rich renderable may expand beyond optimal. Defaults to False. - shrink (bool, optional): Rich renderable may shrink below optional. Defaults to False. + expand (bool, optional): Expand content if required to fill container. Defaults to False. + shrink (bool, optional): Shrink content if required to fill container. Defaults to False. name (str | None, optional): Name of widget. Defaults to None. id (str | None, optional): ID of Widget. Defaults to None. classes (str | None, optional): Space separated list of class names. Defaults to None. @@ -49,8 +49,8 @@ class Static(Widget): self, renderable: RenderableType = "", *, - expand: bool = True, - shrink: bool = True, + expand: bool = False, + shrink: bool = False, markup: bool = True, name: str | None = None, id: str | None = None,