-
I have a difficulty creating a A container between other elements which is using the needed height of it's childs. Here is an example of the expected result: I thought by adding The actual result is, that the container disappears: Is there a possibility to get the expected result with Attached is an example code: It uses the defaults ( Thank you for any help or alternatives to get the result. from __future__ import annotations
from textual.app import App, ComposeResult
from textual.containers import Container, Vertical, Horizontal
from textual.widgets import Header, Footer, Static
from textual import log
class LayoutTestApp(App):
BINDINGS = [
("a", "toggle_auto", "Set Grid: height=auto")
]
DEFAULT_CSS = """
.title {
text-style: bold;
}
#grid_layout {
layout: grid;
grid-size: 3 3;
grid-gutter: 1;
background: $panel;
/* added by key "a" */
/* height: auto; */
}
#grid_layout Static {
background: $boost;
}
"""
def compose(self) -> ComposeResult:
yield Header()
yield Footer()
yield Container(
Vertical(
Static("A Title", classes="title"),
Horizontal(
Static("Box"),
Static("Box"),
Static("Box"),
Static("Box"),
Static("A Box with a longer text which breaks and has 2-3 lines of text."),
Static("Box"),
Static("Box"),
Static("Box"),
Static("Box"),
id="grid_layout"
),
Static("A Text after the grid"),
)
)
def action_toggle_auto(self) -> None:
log("toggle auto")
log("value before:")
log(self.query_one("#grid_layout").styles.height)
self.query_one("#grid_layout").styles.height = "auto"
log("value after:")
log(self.query_one("#grid_layout").styles.height)
if __name__ == "__main__":
app = LayoutTestApp()
app.run() |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It's worth noting, just because you mentioned it, but the docs do highlight that you shouldn't have web browser grid in mind when looking at Textual's grid. That aside, checking here I'm told that a |
Beta Was this translation helpful? Give feedback.
It's worth noting, just because you mentioned it, but the docs do highlight that you shouldn't have web browser grid in mind when looking at Textual's grid.
That aside, checking here I'm told that a
grid
container should handleheight: auto
so this is looking like a bug. I'll raise an issue to that effect.