renderer refactor

This commit is contained in:
Will McGugan
2021-07-29 16:53:54 +01:00
parent ecc5d24b54
commit 6cb25add4a
13 changed files with 187 additions and 66 deletions

5
examples/README.md Normal file
View File

@@ -0,0 +1,5 @@
# Examples
Run any of these examples to demonstrate a features.
These examples may not be feature complete, but they should be somewhat useful and a good starting point for your own code.

20
examples/test_layout.py Normal file
View File

@@ -0,0 +1,20 @@
from rich import print
from rich.console import Console
from textual.geometry import Offset, Region
from textual.widgets import Placeholder
from textual.views import WindowView
p = Placeholder(height=10)
view = WindowView(p)
console = Console()
view.layout.reflow(console, 30, 25, Offset(0, 3))
print(view.layout._layout_map.widgets)
console.print(view.layout.render(console))
# console.print(view.layout.render(console, Region(100, 2, 10, 10)))

19
examples/vertical.py Normal file
View File

@@ -0,0 +1,19 @@
from textual import events
from textual.app import App
from textual.views import WindowView
from textual.widgets import Placeholder
class MyApp(App):
async def on_mount(self, event: events.Mount) -> None:
window1 = WindowView(Placeholder(height=20))
# window2 = WindowView(Placeholder(height=20))
# window1.scroll_x = -10
# window1.scroll_y = 5
await self.view.dock(window1, edge="left")
MyApp.run(log="textual.log")