Bug: bottom item appears below screen #980
-
Hi. I've been messing around in the Here's some code: from textual.app import App, ComposeResult
from textual.containers import Container, Horizontal
from textual.widgets import Static
from rich.text import Text
class WithWidth(Static):
DEFAULT_CSS = """
WithWidth {
width: 3;
}
"""
class MyApp(App):
def compose(self) -> ComposeResult:
yield Container(Horizontal(WithWidth("foo"), Static("bar")), Static("baz")) The resulting app looks like this:
It seems like textual is trying to put Here's an asciicast which shows the problem https://asciinema.org/a/jj7bsil2pCx55MMzeqFAMDn6H Another thing that I think is kind of weird is that if you make this edit:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Applying |
Beta Was this translation helpful? Give feedback.
-
I think you have a parenthesis in the wrong place. Here's your code reformatted a little: from textual.app import App, ComposeResult
from textual.containers import Container, Horizontal
from textual.widgets import Static
from rich.text import Text
class WithWidth(Static):
DEFAULT_CSS = """
WithWidth {
width: 3;
}
"""
class MyApp(App):
def compose(self) -> ComposeResult:
yield Container(
Horizontal(WithWidth("foo"), Static("bar")),
Static("baz"),
) Inside your container you have a horizontal (which takes up the full screen), followed by a Static, which accounts for your extra line. Suspect you meant something like the following? from textual.app import App, ComposeResult
from textual.containers import Container, Horizontal
from textual.widgets import Static
from rich.text import Text
class WithWidth(Static):
DEFAULT_CSS = """
WithWidth {
width: 3;
}
"""
class MyApp(App):
def compose(self) -> ComposeResult:
yield Container(
Horizontal(
WithWidth("foo"),
WithWidth("bar"),
WithWidth("baz"),
)
) |
Beta Was this translation helpful? Give feedback.
-
Oh I see. I was overlooking that Horizontal takes up the whole screen. I had expected something like:
A long time ago (and the last time I bothered with a UI) I did some work with WPF StackPanels and I had mistakendly assumed that Horizontal would work like one of those (which don't expand to fill available space). Thanks for your answer. |
Beta Was this translation helpful? Give feedback.
I think you have a parenthesis in the wrong place. Here's your code reformatted a little:
Inside your container you have a horizontal (which takes up the full screen), followed by a Static, which accounts for your extra line.
Suspect you meant som…