Update tests to handle scroll changes to Container

See #2361.
This commit is contained in:
Dave Pearson
2023-04-24 11:10:37 +01:00
parent a91b2c6b35
commit b896e9d7f9
8 changed files with 23 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
from textual.app import App from textual.app import App
from textual.containers import Container from textual.containers import ScrollableContainer
from textual.widgets import Label from textual.widgets import Label
TEXT = """I must not fear. TEXT = """I must not fear.
@@ -14,7 +14,7 @@ Where the fear has gone there will be nothing. Only I will remain.
class ScrollbarApp(App): class ScrollbarApp(App):
def compose(self): def compose(self):
yield Container(Label(TEXT * 5), classes="panel") yield ScrollableContainer(Label(TEXT * 5), classes="panel")
app = ScrollbarApp(css_path="scrollbar_size.css") app = ScrollbarApp(css_path="scrollbar_size.css")

View File

@@ -1,4 +1,4 @@
Container { ScrollableContainer {
width: 1fr; width: 1fr;
} }

View File

@@ -1,5 +1,5 @@
from textual.app import App from textual.app import App
from textual.containers import Horizontal, Container from textual.containers import Horizontal, ScrollableContainer
from textual.widgets import Label from textual.widgets import Label
TEXT = """I must not fear. TEXT = """I must not fear.
@@ -15,10 +15,12 @@ Where the fear has gone there will be nothing. Only I will remain.
class ScrollbarApp(App): class ScrollbarApp(App):
def compose(self): def compose(self):
yield Horizontal( yield Horizontal(
Container(Label(TEXT * 5), id="v1"), ScrollableContainer(Label(TEXT * 5), id="v1"),
Container(Label(TEXT * 5), id="v2"), ScrollableContainer(Label(TEXT * 5), id="v2"),
Container(Label(TEXT * 5), id="v3"), ScrollableContainer(Label(TEXT * 5), id="v3"),
) )
app = ScrollbarApp(css_path="scrollbar_size2.css") app = ScrollbarApp(css_path="scrollbar_size2.css")
if __name__ == "__main__":
app.run()

View File

@@ -9,6 +9,6 @@ Label {
scrollbar-corner-color: blue; scrollbar-corner-color: blue;
} }
Horizontal > Container { Horizontal > ScrollableContainer {
width: 50%; width: 50%;
} }

View File

@@ -1,5 +1,5 @@
from textual.app import App from textual.app import App
from textual.containers import Horizontal, Container from textual.containers import Horizontal, ScrollableContainer
from textual.widgets import Label from textual.widgets import Label
TEXT = """I must not fear. TEXT = """I must not fear.
@@ -15,9 +15,11 @@ Where the fear has gone there will be nothing. Only I will remain.
class ScrollbarApp(App): class ScrollbarApp(App):
def compose(self): def compose(self):
yield Horizontal( yield Horizontal(
Container(Label(TEXT * 10)), ScrollableContainer(Label(TEXT * 10)),
Container(Label(TEXT * 10), classes="right"), ScrollableContainer(Label(TEXT * 10), classes="right"),
) )
app = ScrollbarApp(css_path="scrollbars.css") app = ScrollbarApp(css_path="scrollbars.css")
if __name__ == "__main__":
app.run()

View File

@@ -1,5 +1,7 @@
from rich.align import VerticalCenter
from textual.app import App, ComposeResult from textual.app import App, ComposeResult
from textual.containers import Horizontal from textual.containers import Horizontal, VerticalScroll
from textual.widgets import Button, ContentSwitcher, DataTable, Markdown from textual.widgets import Button, ContentSwitcher, DataTable, Markdown
MARKDOWN_EXAMPLE = """# Three Flavours Cornetto MARKDOWN_EXAMPLE = """# Three Flavours Cornetto
@@ -37,7 +39,8 @@ class ContentSwitcherApp(App[None]):
with ContentSwitcher(initial="data-table"): # (4)! with ContentSwitcher(initial="data-table"): # (4)!
yield DataTable(id="data-table") yield DataTable(id="data-table")
yield Markdown(MARKDOWN_EXAMPLE, id="markdown") with VerticalScroll(id="markdown"):
yield Markdown(MARKDOWN_EXAMPLE)
def on_button_pressed(self, event: Button.Pressed) -> None: def on_button_pressed(self, event: Button.Pressed) -> None:
self.query_one(ContentSwitcher).current = event.button.id # (5)! self.query_one(ContentSwitcher).current = event.button.id # (5)!

View File

@@ -79,7 +79,7 @@ class EasingApp(App):
yield duration_input yield duration_input
with Horizontal(): with Horizontal():
yield self.animated_bar yield self.animated_bar
yield Container(self.opacity_widget, id="other") yield VerticalScroll(self.opacity_widget, id="other")
yield Footer() yield Footer()
def on_button_pressed(self, event: Button.Pressed) -> None: def on_button_pressed(self, event: Button.Pressed) -> None:

View File

@@ -2,7 +2,7 @@ from os import urandom
from random import randrange from random import randrange
from textual.app import App from textual.app import App
from textual.containers import Container, Horizontal, Vertical from textual.containers import Container, Horizontal, ScrollableContainer, Vertical
from textual.screen import Screen from textual.screen import Screen
from textual.widgets import DataTable, Header, Label from textual.widgets import DataTable, Header, Label
@@ -109,7 +109,7 @@ class Rendering(LabeledBox):
super().__init__( super().__init__(
"", "",
Container( ScrollableContainer(
Horizontal(self.__info, id="issue-info"), Horizontal(self.__info, id="issue-info"),
Horizontal(*[Status(str(i)) for i in range(4)], id="statuses-box"), Horizontal(*[Status(str(i)) for i in range(4)], id="statuses-box"),
id="issues-box", id="issues-box",