mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Expanding fr (#2221)
* forced fr to expand * margin size * remove comment * missing snapshot * snapshot tests * changelog * optimize * snapshot fix * snapshot update * snapshot and fixes * docstrings [skip ci]
This commit is contained in:
File diff suppressed because one or more lines are too long
40
tests/snapshot_tests/snapshot_apps/auto_fr.py
Normal file
40
tests/snapshot_tests/snapshot_apps/auto_fr.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Label
|
||||
|
||||
|
||||
class FRApp(App):
|
||||
CSS = """
|
||||
Screen {
|
||||
align: center middle;
|
||||
border: solid cyan;
|
||||
}
|
||||
|
||||
#container {
|
||||
width: 30;
|
||||
height: auto;
|
||||
border: solid green;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#child {
|
||||
height: 1fr;
|
||||
border: solid red;
|
||||
}
|
||||
|
||||
#bottom {
|
||||
margin: 1 2;
|
||||
background: $primary;
|
||||
}
|
||||
"""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with Widget(id="container"):
|
||||
yield Label("Hello one line", id="top")
|
||||
yield Widget(id="child")
|
||||
yield Label("Two\nLines with 1x2 margin", id="bottom")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = FRApp()
|
||||
app.run()
|
||||
35
tests/snapshot_tests/snapshot_apps/fr_margins.py
Normal file
35
tests/snapshot_tests/snapshot_apps/fr_margins.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Label
|
||||
from textual.containers import Container
|
||||
|
||||
|
||||
# Test fr dimensions and margins work in an auto container
|
||||
# https://github.com/Textualize/textual/issues/2220
|
||||
class TestApp(App):
|
||||
CSS = """
|
||||
Container {
|
||||
background: green 20%;
|
||||
border: heavy green;
|
||||
width: auto;
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
Label {
|
||||
background: green 20%;
|
||||
width: 1fr;
|
||||
height: 1fr;
|
||||
margin: 2 2;
|
||||
}
|
||||
"""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with Container():
|
||||
yield Label("Hello")
|
||||
yield Label("World")
|
||||
yield Label("!!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = TestApp()
|
||||
app.run()
|
||||
@@ -388,6 +388,16 @@ def test_dock_scroll(snap_compare):
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "dock_scroll.py", terminal_size=(80, 25))
|
||||
|
||||
|
||||
def test_auto_fr(snap_compare):
|
||||
# https://github.com/Textualize/textual/issues/2220
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "auto_fr.py", terminal_size=(80, 25))
|
||||
|
||||
|
||||
def test_fr_margins(snap_compare):
|
||||
# https://github.com/Textualize/textual/issues/2220
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "fr_margins.py", terminal_size=(80, 25))
|
||||
|
||||
|
||||
def test_scroll_visible(snap_compare):
|
||||
# https://github.com/Textualize/textual/issues/2181
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "scroll_visible.py", press=["t"])
|
||||
|
||||
Reference in New Issue
Block a user