Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/examples/how-to/containers01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

def compose(self) -> ComposeResult:
with Horizontal(): # (1)!
yield Box() # (2)!
yield Box()
yield Box()


if __name__ == "__main__":
app = ContainerApp()
app.run()
29 changes: 29 additions & 0 deletions docs/examples/how-to/containers02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

def compose(self) -> ComposeResult:
with Vertical(): # (1)!
yield Box()
yield Box()
yield Box()


if __name__ == "__main__":
app = ContainerApp()
app.run()
35 changes: 35 additions & 0 deletions docs/examples/how-to/containers03.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

CSS = """
.with-border {
border: heavy green;
}
"""

def compose(self) -> ComposeResult:
with Horizontal(classes="with-border"): # (1)!
yield Box()
yield Box()
yield Box()


if __name__ == "__main__":
app = ContainerApp()
app.run()
39 changes: 39 additions & 0 deletions docs/examples/how-to/containers04.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

CSS = """
.with-border {
border: heavy green;
}
"""

def compose(self) -> ComposeResult:
with Horizontal(classes="with-border"):
yield Box()
yield Box()
yield Box()
with Horizontal(classes="with-border"):
yield Box()
yield Box()
yield Box()


if __name__ == "__main__":
app = ContainerApp()
app.run()
39 changes: 39 additions & 0 deletions docs/examples/how-to/containers05.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from textual.app import App, ComposeResult
from textual.containers import HorizontalGroup
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

CSS = """
.with-border {
border: heavy green;
}
"""

def compose(self) -> ComposeResult:
with HorizontalGroup(classes="with-border"):
yield Box()
yield Box()
yield Box()
with HorizontalGroup(classes="with-border"):
yield Box()
yield Box()
yield Box()


if __name__ == "__main__":
app = ContainerApp()
app.run()
34 changes: 34 additions & 0 deletions docs/examples/how-to/containers06.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

CSS = """
.with-border {
border: heavy green;
}
"""

def compose(self) -> ComposeResult:
with Horizontal(classes="with-border"):
for n in range(10):
yield Box(label=f"Box {n+1}")


if __name__ == "__main__":
app = ContainerApp()
app.run()
34 changes: 34 additions & 0 deletions docs/examples/how-to/containers07.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from textual.app import App, ComposeResult
from textual.containers import HorizontalScroll
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

CSS = """
.with-border {
border: heavy green;
}
"""

def compose(self) -> ComposeResult:
with HorizontalScroll(classes="with-border"):
for n in range(10):
yield Box(label=f"Box {n+1}")


if __name__ == "__main__":
app = ContainerApp()
app.run()
36 changes: 36 additions & 0 deletions docs/examples/how-to/containers08.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from textual.app import App, ComposeResult
from textual.containers import Center, Right
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 5;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

CSS = """
.with-border {
border: heavy green;
}
"""

def compose(self) -> ComposeResult:
yield Box("Box 1") # (1)!
with Center(classes="with-border"): # (2)!
yield Box("Box 2")
with Right(classes="with-border"): # (3)!
yield Box("Box 3")


if __name__ == "__main__":
app = ContainerApp()
app.run()
35 changes: 35 additions & 0 deletions docs/examples/how-to/containers09.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from textual.app import App, ComposeResult
from textual.containers import Middle
from textual.widgets import Placeholder


class Box(Placeholder):
"""Example widget."""

DEFAULT_CSS = """
Box {
width: 16;
height: 5;
}
"""


class ContainerApp(App):
"""Simple app to play with containers."""

CSS = """
.with-border {
border: heavy green;
}
"""

def compose(self) -> ComposeResult:
with Middle(classes="with-border"): # (1)!
yield Box("Box 1.")
yield Box("Box 2.")
yield Box("Box 3.")


if __name__ == "__main__":
app = ContainerApp()
app.run()
Loading
Loading