mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
doc screenshots
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
Stopwatch {
|
Stopwatch {
|
||||||
layout: horizontal;
|
layout: horizontal;
|
||||||
background: $panel-darken-1;
|
background: $boost;
|
||||||
height: 5;
|
height: 5;
|
||||||
min-width: 50;
|
min-width: 50;
|
||||||
margin: 1;
|
margin: 1;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Stopwatch {
|
Stopwatch {
|
||||||
layout: horizontal;
|
layout: horizontal;
|
||||||
background: $panel-darken-1;
|
background: $boost;
|
||||||
height: 5;
|
height: 5;
|
||||||
padding: 1;
|
padding: 1;
|
||||||
margin: 1;
|
margin: 1;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Stopwatch {
|
Stopwatch {
|
||||||
layout: horizontal;
|
layout: horizontal;
|
||||||
background: $panel-darken-1;
|
background: $boost;
|
||||||
height: 5;
|
height: 5;
|
||||||
min-width: 50;
|
min-width: 50;
|
||||||
margin: 1;
|
margin: 1;
|
||||||
|
|||||||
@@ -59,18 +59,21 @@ Textual is a framework for building applications that run within your terminal.
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
|
||||||
```{.textual path="examples/calculator.py" columns=100 lines=41 press="3,.,1,4,5,9,2,_,_"}
|
```{.textual path="examples/calculator.py" columns=100 lines=41 press="3,.,1,4,5,9,2,_,_,_,_,_,_,_,_"}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```{.textual path="examples/pride.py"}
|
```{.textual path="examples/pride.py"}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```{.textual path="docs/examples/tutorial/stopwatch.py" press="tab,enter,_,_"}
|
```{.textual path="docs/examples/tutorial/stopwatch.py" columns="100" lines="30" press="d,tab,enter,_,_"}
|
||||||
```
|
```
|
||||||
|
|
||||||
```{.textual path="docs/examples/guide/layout/combining_layouts.py"}
|
|
||||||
|
```{.textual path="docs/examples/events/dictionary.py" columns="100" lines="30" press="tab,_,t,e,x,t,_,_,_,_,_,_,_,_,_,_,_,_,_"}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```{.textual path="docs/examples/guide/layout/combining_layouts.py" columns="100", lines="30"}
|
||||||
```
|
```
|
||||||
|
|
||||||
```{.textual path="docs/examples/app/widgets01.py"}
|
```{.textual path="docs/examples/app/widgets01.py"}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ CSS files contain a number of _declaration blocks_. Here's the first such block
|
|||||||
```sass
|
```sass
|
||||||
Stopwatch {
|
Stopwatch {
|
||||||
layout: horizontal;
|
layout: horizontal;
|
||||||
background: $panel-darken-1;
|
background: $boost;
|
||||||
height: 5;
|
height: 5;
|
||||||
padding: 1;
|
padding: 1;
|
||||||
margin: 1;
|
margin: 1;
|
||||||
@@ -240,7 +240,7 @@ Here's how this CSS code changes how the `Stopwatch` widget is displayed.
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
- `layout: horizontal` aligns child widgets horizontally from left to right.
|
- `layout: horizontal` aligns child widgets horizontally from left to right.
|
||||||
- `background: $panel-darken-1` sets the background color to `$panel-darken-1`. The `$` prefix picks a pre-defined color from the builtin theme. There are other ways to specify colors such as `"blue"` or `rgb(20,46,210)`.
|
- `background: $boost` sets the background color to `$boost`. The `$` prefix picks a pre-defined color from the builtin theme. There are other ways to specify colors such as `"blue"` or `rgb(20,46,210)`.
|
||||||
- `height: 5` sets the height of our widget to 5 lines of text.
|
- `height: 5` sets the height of our widget to 5 lines of text.
|
||||||
- `padding: 1` sets a padding of 1 cell around the child widgets.
|
- `padding: 1` sets a padding of 1 cell around the child widgets.
|
||||||
- `margin: 1` sets a margin of 1 cell around the Stopwatch widget to create a little space between widgets in the list.
|
- `margin: 1` sets a margin of 1 cell around the Stopwatch widget to create a little space between widgets in the list.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Screen {
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#calculator {
|
#calculator {
|
||||||
layout: grid;
|
layout: grid;
|
||||||
grid-size: 4;
|
grid-size: 4;
|
||||||
grid-gutter: 1 2;
|
grid-gutter: 1 2;
|
||||||
|
|||||||
@@ -154,10 +154,11 @@ class Animator:
|
|||||||
callback=self,
|
callback=self,
|
||||||
pause=True,
|
pause=True,
|
||||||
)
|
)
|
||||||
|
self._idle_event = asyncio.Event()
|
||||||
|
|
||||||
async def start(self) -> None:
|
async def start(self) -> None:
|
||||||
"""Start the animator task."""
|
"""Start the animator task."""
|
||||||
|
self._idle_event.set()
|
||||||
self._timer.start()
|
self._timer.start()
|
||||||
|
|
||||||
async def stop(self) -> None:
|
async def stop(self) -> None:
|
||||||
@@ -296,10 +297,12 @@ class Animator:
|
|||||||
|
|
||||||
self._animations[animation_key] = animation
|
self._animations[animation_key] = animation
|
||||||
self._timer.resume()
|
self._timer.resume()
|
||||||
|
self._idle_event.clear()
|
||||||
|
|
||||||
async def __call__(self) -> None:
|
async def __call__(self) -> None:
|
||||||
if not self._animations:
|
if not self._animations:
|
||||||
self._timer.pause()
|
self._timer.pause()
|
||||||
|
self._idle_event.set()
|
||||||
else:
|
else:
|
||||||
animation_time = self._get_time()
|
animation_time = self._get_time()
|
||||||
animation_keys = list(self._animations.keys())
|
animation_keys = list(self._animations.keys())
|
||||||
@@ -317,3 +320,7 @@ class Animator:
|
|||||||
# N.B. We could remove this method and always call `self._timer.get_time()` internally,
|
# N.B. We could remove this method and always call `self._timer.get_time()` internally,
|
||||||
# but it's handy to have in mocking situations
|
# but it's handy to have in mocking situations
|
||||||
return _clock.get_time_no_wait()
|
return _clock.get_time_no_wait()
|
||||||
|
|
||||||
|
async def wait_for_idle(self) -> None:
|
||||||
|
"""Wait for any animations to complete."""
|
||||||
|
await self._idle_event.wait()
|
||||||
|
|||||||
@@ -664,6 +664,9 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
events.Key(self, key, key if len(key) == 1 else None)
|
events.Key(self, key, key if len(key) == 1 else None)
|
||||||
)
|
)
|
||||||
await asyncio.sleep(0.01)
|
await asyncio.sleep(0.01)
|
||||||
|
|
||||||
|
await app._animator.wait_for_idle()
|
||||||
|
|
||||||
if screenshot:
|
if screenshot:
|
||||||
self._screenshot = self.export_screenshot(
|
self._screenshot = self.export_screenshot(
|
||||||
title=screenshot_title
|
title=screenshot_title
|
||||||
|
|||||||
Reference in New Issue
Block a user