Merge branch 'css' of github.com:Textualize/textual into text-justify

This commit is contained in:
Darren Burns
2022-08-25 16:33:54 +01:00
17 changed files with 203 additions and 70 deletions

View File

@@ -1,11 +1,11 @@
from __future__ import annotations
import asyncio
from rich.console import RenderableType
from rich.panel import Panel
from textual import events
from textual.app import App, ComposeResult
from textual.layout import Horizontal, Vertical
from textual.widget import Widget
@@ -18,37 +18,22 @@ class Box(Widget, can_focus=True):
super().__init__(*children, id=id, classes=classes)
def render(self) -> RenderableType:
return Panel("Box")
return "Box"
class JustABox(App):
def compose(self) -> ComposeResult:
yield Horizontal(
Vertical(
Box(id="box1", classes="box"),
Box(id="box2", classes="box"),
# Box(id="box3", classes="box"),
# Box(id="box4", classes="box"),
# Box(id="box5", classes="box"),
# Box(id="box6", classes="box"),
# Box(id="box7", classes="box"),
# Box(id="box8", classes="box"),
# Box(id="box9", classes="box"),
# Box(id="box10", classes="box"),
id="left_pane",
),
Box(id="middle_pane"),
Vertical(
Box(id="boxa", classes="box"),
Box(id="boxb", classes="box"),
Box(id="boxc", classes="box"),
id="right_pane",
),
id="horizontal",
)
self.box = Box()
yield self.box
def key_p(self):
print(self.query("#horizontal").first().styles.layout)
def key_a(self):
self.animator.animate(
self.box.styles,
"opacity",
value=0.0,
duration=2.0,
on_complete=self.box.remove,
)
async def on_key(self, event: events.Key) -> None:
await self.dispatch_key(event)