mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -6,9 +6,10 @@ except ImportError:
|
||||
raise ImportError("Please install httpx with 'pip install httpx' ")
|
||||
|
||||
from rich.json import JSON
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Vertical
|
||||
from textual.widgets import Static, Input
|
||||
from textual.containers import VerticalScroll
|
||||
from textual.widgets import Input, Static
|
||||
|
||||
|
||||
class DictionaryApp(App):
|
||||
@@ -18,7 +19,7 @@ class DictionaryApp(App):
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Input(placeholder="Search for a word")
|
||||
yield Vertical(Static(id="results"), id="results-container")
|
||||
yield VerticalScroll(Static(id="results"), id="results-container")
|
||||
|
||||
async def on_input_changed(self, message: Input.Changed) -> None:
|
||||
"""A coroutine to handle a text changed message."""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container, Horizontal, Vertical
|
||||
from textual.containers import Container, Horizontal, VerticalScroll
|
||||
from textual.widgets import Header, Static
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class CombiningLayoutsExample(App):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
with Container(id="app-grid"):
|
||||
with Vertical(id="left-pane"):
|
||||
with VerticalScroll(id="left-pane"):
|
||||
for number in range(15):
|
||||
yield Static(f"Vertical layout, child {number}")
|
||||
with Horizontal(id="top-right"):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Horizontal, Vertical
|
||||
from textual.containers import Horizontal, VerticalScroll
|
||||
from textual.widgets import Static
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ class UtilityContainersExample(App):
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Horizontal(
|
||||
Vertical(
|
||||
VerticalScroll(
|
||||
Static("One"),
|
||||
Static("Two"),
|
||||
classes="column",
|
||||
),
|
||||
Vertical(
|
||||
VerticalScroll(
|
||||
Static("Three"),
|
||||
Static("Four"),
|
||||
classes="column",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Horizontal, Vertical
|
||||
from textual.containers import Horizontal, VerticalScroll
|
||||
from textual.widgets import Static
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ class UtilityContainersExample(App):
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with Horizontal():
|
||||
with Vertical(classes="column"):
|
||||
with VerticalScroll(classes="column"):
|
||||
yield Static("One")
|
||||
yield Static("Two")
|
||||
with Vertical(classes="column"):
|
||||
with VerticalScroll(classes="column"):
|
||||
yield Static("Three")
|
||||
yield Static("Four")
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Vertical
|
||||
from textual.widgets import Placeholder, Label, Static
|
||||
from textual.containers import VerticalScroll
|
||||
from textual.widgets import Label, Placeholder, Static
|
||||
|
||||
|
||||
class Ruler(Static):
|
||||
@@ -11,7 +11,7 @@ class Ruler(Static):
|
||||
|
||||
class HeightComparisonApp(App):
|
||||
def compose(self):
|
||||
yield Vertical(
|
||||
yield VerticalScroll(
|
||||
Placeholder(id="cells"), # (1)!
|
||||
Placeholder(id="percent"),
|
||||
Placeholder(id="w"),
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Vertical
|
||||
from textual.containers import VerticalScroll
|
||||
from textual.widgets import Placeholder
|
||||
|
||||
|
||||
class MaxWidthApp(App):
|
||||
def compose(self):
|
||||
yield Vertical(
|
||||
yield VerticalScroll(
|
||||
Placeholder("max-width: 50h", id="p1"),
|
||||
Placeholder("max-width: 999", id="p2"),
|
||||
Placeholder("max-width: 50%", id="p3"),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Vertical {
|
||||
VerticalScroll {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
@@ -10,7 +10,8 @@ Placeholder {
|
||||
}
|
||||
|
||||
#p1 {
|
||||
min-width: 25%; /* (1)! */
|
||||
min-width: 25%;
|
||||
/* (1)! */
|
||||
}
|
||||
|
||||
#p2 {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Vertical
|
||||
from textual.containers import VerticalScroll
|
||||
from textual.widgets import Placeholder
|
||||
|
||||
|
||||
class MinWidthApp(App):
|
||||
def compose(self):
|
||||
yield Vertical(
|
||||
yield VerticalScroll(
|
||||
Placeholder("min-width: 25%", id="p1"),
|
||||
Placeholder("min-width: 75%", id="p2"),
|
||||
Placeholder("min-width: 100", id="p3"),
|
||||
|
||||
@@ -3,7 +3,7 @@ Screen {
|
||||
color: black;
|
||||
}
|
||||
|
||||
Vertical {
|
||||
VerticalScroll {
|
||||
width: 1fr;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ Static {
|
||||
border: green wide;
|
||||
color: white 90%;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
#right {
|
||||
overflow-y: hidden;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Horizontal, VerticalScroll
|
||||
from textual.widgets import Static
|
||||
from textual.containers import Horizontal, Vertical
|
||||
|
||||
TEXT = """I must not fear.
|
||||
Fear is the mind-killer.
|
||||
@@ -14,8 +14,8 @@ Where the fear has gone there will be nothing. Only I will remain."""
|
||||
class OverflowApp(App):
|
||||
def compose(self):
|
||||
yield Horizontal(
|
||||
Vertical(Static(TEXT), Static(TEXT), Static(TEXT), id="left"),
|
||||
Vertical(Static(TEXT), Static(TEXT), Static(TEXT), id="right"),
|
||||
VerticalScroll(Static(TEXT), Static(TEXT), Static(TEXT), id="left"),
|
||||
VerticalScroll(Static(TEXT), Static(TEXT), Static(TEXT), id="right"),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Vertical
|
||||
from textual.containers import VerticalScroll
|
||||
from textual.widgets import Label
|
||||
|
||||
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):
|
||||
def compose(self):
|
||||
yield Vertical(Label(TEXT * 5), classes="panel")
|
||||
yield VerticalScroll(Label(TEXT * 5), classes="panel")
|
||||
|
||||
|
||||
app = ScrollbarApp(css_path="scrollbar_size.css")
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Horizontal, Vertical
|
||||
from textual.containers import Horizontal, VerticalScroll
|
||||
from textual.widgets import Placeholder
|
||||
|
||||
|
||||
class VisibilityContainersApp(App):
|
||||
def compose(self):
|
||||
yield Vertical(
|
||||
yield VerticalScroll(
|
||||
Horizontal(
|
||||
Placeholder(),
|
||||
Placeholder(),
|
||||
|
||||
@@ -2,7 +2,7 @@ Button {
|
||||
margin: 1 2;
|
||||
}
|
||||
|
||||
Horizontal > Vertical {
|
||||
Horizontal>VerticalScroll {
|
||||
width: 24;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Horizontal, Vertical
|
||||
from textual.containers import Horizontal, VerticalScroll
|
||||
from textual.widgets import Button, Static
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class ButtonsApp(App[str]):
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Horizontal(
|
||||
Vertical(
|
||||
VerticalScroll(
|
||||
Static("Standard Buttons", classes="header"),
|
||||
Button("Default"),
|
||||
Button("Primary!", variant="primary"),
|
||||
@@ -16,7 +16,7 @@ class ButtonsApp(App[str]):
|
||||
Button.warning("Warning!"),
|
||||
Button.error("Error!"),
|
||||
),
|
||||
Vertical(
|
||||
VerticalScroll(
|
||||
Static("Disabled Buttons", classes="header"),
|
||||
Button("Default", disabled=True),
|
||||
Button("Primary!", variant="primary", disabled=True),
|
||||
|
||||
@@ -2,7 +2,7 @@ Screen {
|
||||
align: center middle;
|
||||
}
|
||||
|
||||
Vertical {
|
||||
VerticalScroll {
|
||||
width: auto;
|
||||
height: auto;
|
||||
border: solid $primary;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Vertical
|
||||
from textual.containers import VerticalScroll
|
||||
from textual.widgets import Checkbox
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class CheckboxApp(App[None]):
|
||||
CSS_PATH = "checkbox.css"
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with Vertical():
|
||||
with VerticalScroll():
|
||||
yield Checkbox("Arrakis :sweat:")
|
||||
yield Checkbox("Caladan")
|
||||
yield Checkbox("Chusuk")
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container, Horizontal, Vertical
|
||||
from textual.containers import Container, Horizontal, VerticalScroll
|
||||
from textual.widgets import Placeholder
|
||||
|
||||
|
||||
class PlaceholderApp(App):
|
||||
|
||||
CSS_PATH = "placeholder.css"
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Vertical(
|
||||
yield VerticalScroll(
|
||||
Container(
|
||||
Placeholder("This is a custom label for p1.", id="p1"),
|
||||
Placeholder("Placeholder p2 here!", id="p2"),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Vertical {
|
||||
VerticalScroll {
|
||||
align: center middle;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Horizontal, Vertical
|
||||
from textual.containers import Horizontal, VerticalScroll
|
||||
from textual.widgets import Label, RadioButton, RadioSet
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class RadioSetChangedApp(App[None]):
|
||||
CSS_PATH = "radio_set_changed.css"
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with Vertical():
|
||||
with VerticalScroll():
|
||||
with Horizontal():
|
||||
with RadioSet():
|
||||
yield RadioButton("Battlestar Galactica")
|
||||
|
||||
Reference in New Issue
Block a user