shrink expand

This commit is contained in:
Will McGugan
2022-10-04 10:12:25 +01:00
parent 3c33c7fee7
commit 14e87b6c99
3 changed files with 8 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ DirectoryTree {
#code-view {
overflow: auto scroll;
min-width: 100%;
}
#code {
width: auto;

View File

@@ -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)

View File

@@ -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,