mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
ws
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# Examples
|
||||
|
||||
Run any of these examples to demonstrate a features.
|
||||
Run any of these examples to demonstrate a Textual features.
|
||||
|
||||
These examples may not be feature complete, but they should be somewhat useful and a good starting point for your own code.
|
||||
The example code will generate a log file called "textual.log". Tail this file to gain insight in to what Textual is doing.
|
||||
|
||||
```
|
||||
tail -f textual
|
||||
```
|
||||
|
||||
@@ -11,9 +11,6 @@ class GridTest(App):
|
||||
|
||||
grid = await self.view.dock_grid(edge="left", size=70, name="left")
|
||||
|
||||
# self.view["left"].scroll_y = 5
|
||||
# self.view["left"].scroll_x = 5
|
||||
|
||||
grid.add_column(fraction=1, name="left", min_size=20)
|
||||
grid.add_column(size=30, name="center")
|
||||
grid.add_column(fraction=1, name="right")
|
||||
|
||||
@@ -22,4 +22,4 @@ class GridTest(App):
|
||||
grid.place(*(Placeholder() for _ in range(20)), center=Placeholder())
|
||||
|
||||
|
||||
GridTest.run(title="Grid Test")
|
||||
GridTest.run(title="Grid Test", log="textual.log")
|
||||
|
||||
@@ -9,16 +9,22 @@ class MyApp(App):
|
||||
"""An example of a very simple Textual App"""
|
||||
|
||||
async def on_load(self, event: events.Load) -> None:
|
||||
"""Bind keys with the app loads (but before entering application mode)"""
|
||||
await self.bind("b", "view.toggle('sidebar')", "Toggle sidebar")
|
||||
await self.bind("q", "quit", "Quit")
|
||||
|
||||
async def on_mount(self, event: events.Mount) -> None:
|
||||
"""Create and dock the widgets."""
|
||||
|
||||
# A scrollview to contain the markdown file
|
||||
body = ScrollView()
|
||||
|
||||
# Header / footer / dock
|
||||
await self.view.dock(Header(), edge="top")
|
||||
await self.view.dock(Footer(), edge="bottom")
|
||||
await self.view.dock(Placeholder(), edge="left", size=30, name="sidebar")
|
||||
|
||||
# Dock the body in the remaining space
|
||||
await self.view.dock(body, edge="right")
|
||||
|
||||
async def get_markdown(filename: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user