mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Avoid docks when scrolling (#2571)
* handle docked layers * handle scroll better * snapshot update * remove commented out code * superflous * dock gutter * snapshit * snapshit test * changelog * mistake * docstrings * changelog * whitespace * missing punctuation * ofx docstring * Apply suggestions from code review Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> --------- Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
This commit is contained in:
33
tests/snapshot_tests/snapshot_apps/dock_scroll2.py
Normal file
33
tests/snapshot_tests/snapshot_apps/dock_scroll2.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from textual.app import App
|
||||
from textual.widgets import Header, Label, Footer
|
||||
|
||||
|
||||
# Same as dock_scroll.py but with 2 labels
|
||||
class TestApp(App):
|
||||
BINDINGS = [("ctrl+q", "app.quit", "Quit")]
|
||||
CSS = """
|
||||
|
||||
Label {
|
||||
border: solid red;
|
||||
}
|
||||
Footer {
|
||||
height: 4;
|
||||
}
|
||||
"""
|
||||
|
||||
def compose(self):
|
||||
text = (
|
||||
"this is a sample sentence and here are some words".replace(" ", "\n") * 2
|
||||
)
|
||||
yield Header()
|
||||
yield Label(text)
|
||||
yield Label(text)
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self):
|
||||
self.dark = False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = TestApp()
|
||||
app.run()
|
||||
17
tests/snapshot_tests/snapshot_apps/dock_scroll_off_by_one.py
Normal file
17
tests/snapshot_tests/snapshot_apps/dock_scroll_off_by_one.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Checkbox, Footer
|
||||
|
||||
|
||||
class ScrollOffByOne(App):
|
||||
def compose(self) -> ComposeResult:
|
||||
for number in range(1, 100):
|
||||
yield Checkbox(str(number))
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.query_one("Screen").scroll_end()
|
||||
|
||||
|
||||
app = ScrollOffByOne()
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
@@ -19,6 +19,6 @@
|
||||
|
||||
#horizontal {
|
||||
width: auto;
|
||||
height: auto;
|
||||
height: 4;
|
||||
background: darkslateblue;
|
||||
}
|
||||
}
|
||||
|
||||
19
tests/snapshot_tests/snapshot_apps/scroll_to.py
Normal file
19
tests/snapshot_tests/snapshot_apps/scroll_to.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Checkbox, Footer
|
||||
|
||||
|
||||
class ScrollOffByOne(App):
|
||||
"""Scroll to item 50."""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
for number in range(1, 100):
|
||||
yield Checkbox(str(number), id=f"number-{number}")
|
||||
yield Footer()
|
||||
|
||||
def on_ready(self) -> None:
|
||||
self.query_one("#number-50").scroll_visible()
|
||||
|
||||
|
||||
app = ScrollOffByOne()
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
Reference in New Issue
Block a user