styles docs

This commit is contained in:
Will McGugan
2022-09-10 16:12:35 +01:00
parent 150af18026
commit 39c6dee84f
4 changed files with 33 additions and 8 deletions

View File

@@ -1,5 +1,24 @@
# Styles
Textual provides a large number of *styles* you can use to customize how your app looks and feels. In this chapter will will look at how you can edit styles in your applications.
## Styles object
Every widget class in Textual provides a `styles` object which contains a number of writable attributes. Styles define the position and size of a widget, in addition to color, text style, borders, alignment and much more.
## Box Model
<div class="excalidraw">
--8<-- "docs/images/styles/box.excalidraw.svg"
</div>
TODO: Styles docs
- What are styles
@@ -10,6 +29,3 @@ TODO: Styles docs
- Borders / Outline
<div class="excalidraw">
--8<-- "docs/images/styles/box.excalidraw.svg"
</div>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -59,7 +59,11 @@ Textual is a framework for building applications that run within your terminal.
<hr>
```{.textual path="docs/examples/demo.py" columns=100 lines=48}
```{.textual path="examples/calculator.py" columns=100 lines=40}
```
```{.textual path="examples/pride.py"}
```

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
import runpy
import os
import shlex
from typing import cast, TYPE_CHECKING
if TYPE_CHECKING:
@@ -13,7 +14,9 @@ def format_svg(source, language, css_class, options, md, attrs, **kwargs) -> str
"""A superfences formatter to insert a SVG screenshot."""
try:
path: str = attrs["path"]
cmd: list[str] = shlex.split(attrs["path"])
path = cmd[0]
_press = attrs.get("press", None)
press = [*_press.split(",")] if _press else ["_"]
title = attrs.get("title")
@@ -26,6 +29,8 @@ def format_svg(source, language, css_class, options, md, attrs, **kwargs) -> str
cwd = os.getcwd()
try:
app_vars = runpy.run_path(path)
if "sys" in app_vars:
app_vars["sys"].argv = cmd
app: App = cast("App", app_vars["app"])
app.run(
quit_after=5,