-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with scrollable containers #4187
Comments
It looks like you just need to change Here's a modified example I used to test this, just so I didn't have to awkwardly resize my terminal: from textual.app import App, ComposeResult
from textual.containers import Grid, ScrollableContainer
from textual.widgets import Label
class MyApp(App):
# DEFAULT_CSS = """
CSS = """
Grid {
grid-size: 2;
grid-rows: auto;
height: auto;
}
Label {
height: 1;
background: red;
}
"""
def compose(self) -> ComposeResult:
with ScrollableContainer():
with Grid():
for i in range(1, 101):
yield Label(f"Label {i}")
if __name__ == "__main__":
app = MyApp()
app.run() |
The TabbedContent example was missing the parent widget in the selector - see https://textual.textualize.io/guide/CSS/#selectors Textual maintainers: I'm afraid I haven't kept up with nested CSS, but this might have revealed a bug...? from textual.app import App, ComposeResult
from textual.containers import Grid, ScrollableContainer
from textual.widgets import Label, TabbedContent, TabPane
class MyTabPane(TabPane):
DEFAULT_CSS = """
MyTabPane Grid {
grid-size: 2;
grid-rows: auto;
height: auto;
}
MyTabPane Label {
height: 1;
background: red;
}
"""
def compose(self) -> ComposeResult:
with ScrollableContainer():
with Grid():
for i in range(1, 101):
yield Label(f"Label {i}")
class MyApp(App):
def compose(self) -> ComposeResult:
with TabbedContent():
yield MyTabPane("example")
if __name__ == "__main__":
app = MyApp()
app.run() |
Thank you for correcting me with this CSS. But I still see problems with scrolling. I notice the problem when something is above
The scroll for TabPane is always visible, even when no element is hidden. In addition, when labels |
The best way to diagnose these issues is to add borders around element to see if they are bahaving the way you would expect. i.e.
I'm assuming that is the behaviour you are looking for? from textual.app import App, ComposeResult
from textual.containers import Grid, ScrollableContainer, Horizontal
from textual.widgets import Label, TabbedContent, TabPane
class MyTabContent(ScrollableContainer):
DEFAULT_CSS = """
MyTabContent Grid {
grid-size: 2;
grid-rows: auto;
height: auto;
}
"""
def compose(self) -> ComposeResult:
with Grid():
for i in range(1, 13):
yield Label(f"Label {i}")
class MyApp(App):
CSS = """
TabbedContent {
height: 1fr;
}
TabbedContent ContentSwitcher {
height: 1fr;
}
Horizontal {
height: auto;
}
"""
def compose(self) -> ComposeResult:
with Horizontal():
yield Label("X")
yield Label("X")
with Horizontal():
yield Label("Y")
yield Label("Y")
with TabbedContent():
with TabPane("example"):
yield MyTabContent()
if __name__ == "__main__":
app = MyApp()
app.run() |
That's it, thank you very much! It was the missing |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
There seems to be a problem with scrollable containers. Consider an example:
In this case I would expect the scroll to appear when the
Fifth
andSixth
labels are hidden, but:There is no reaction.
After adding some padding, scroll appears when all the labels are hidden, and when I scroll down I don't see any of them.
I have noticed a similar problem with
TabbedContent
:This is when the scroll appears and again I can't see any element that is under the
ScrollableContainer
.The text was updated successfully, but these errors were encountered: