mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge pull request #916 from davep/css-docs-review-actions
CSS docs review - Actions
This commit is contained in:
@@ -42,7 +42,7 @@ Action strings have the following format:
|
|||||||
|
|
||||||
- The name of an action on is own will call the action method with no parameters. For example, an action string of `"bell"` will call `action_bell()`.
|
- The name of an action on is own will call the action method with no parameters. For example, an action string of `"bell"` will call `action_bell()`.
|
||||||
- Actions may be followed by braces containing Python objects. For example, the action string `set_background("red")` will call `action_set_background("red")`.
|
- Actions may be followed by braces containing Python objects. For example, the action string `set_background("red")` will call `action_set_background("red")`.
|
||||||
- Actions may be prefixed with a _namespace_ (see below) follow by a dot.
|
- Actions may be prefixed with a _namespace_ (see below) follow by a dot.
|
||||||
|
|
||||||
<div class="excalidraw">
|
<div class="excalidraw">
|
||||||
--8<-- "docs/images/actions/format.excalidraw.svg"
|
--8<-- "docs/images/actions/format.excalidraw.svg"
|
||||||
@@ -50,7 +50,7 @@ Action strings have the following format:
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
If the action strings contains parameters, these must be valid Python literals. Which means you can include numbers, strings, dicts, lists etc. but you can't include variables or references to any other python symbols.
|
If the action string contains parameters, these must be valid Python literals. Which means you can include numbers, strings, dicts, lists etc. but you can't include variables or references to any other python symbol.
|
||||||
|
|
||||||
Consequently `"set_background('blue')"` is a valid action string, but `"set_background(new_color)"` is not — because `new_color` is a variable and not a literal.
|
Consequently `"set_background('blue')"` is a valid action string, but `"set_background(new_color)"` is not — because `new_color` is a variable and not a literal.
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ The following example mounts simple static text with embedded action links.
|
|||||||
```{.textual path="docs/examples/guide/actions/actions03.py"}
|
```{.textual path="docs/examples/guide/actions/actions03.py"}
|
||||||
```
|
```
|
||||||
|
|
||||||
When you click any of the links, Textual runs the `"set_background"` action to change the background to the given color and plays the terminals bell.
|
When you click any of the links, Textual runs the `"set_background"` action to change the background to the given color and plays the terminal's bell.
|
||||||
|
|
||||||
## Bindings
|
## Bindings
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ The following example defines a custom widget with its own `set_background` acti
|
|||||||
|
|
||||||
=== "actions05.css"
|
=== "actions05.css"
|
||||||
|
|
||||||
```sass title="actions05.css"
|
```sass title="actions05.css"
|
||||||
--8<-- "docs/examples/guide/actions/actions05.css"
|
--8<-- "docs/examples/guide/actions/actions05.css"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
self.dark = not self.dark
|
self.dark = not self.dark
|
||||||
|
|
||||||
def action_screenshot(self, filename: str | None, path: str = "~/") -> None:
|
def action_screenshot(self, filename: str | None, path: str = "~/") -> None:
|
||||||
"""Save an SVG "screenshot". This action will save a SVG file containing the current contents of the screen.
|
"""Save an SVG "screenshot". This action will save an SVG file containing the current contents of the screen.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename (str | None, optional): Filename of screenshot, or None to auto-generate. Defaults to None.
|
filename (str | None, optional): Filename of screenshot, or None to auto-generate. Defaults to None.
|
||||||
@@ -492,7 +492,7 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
self.save_screenshot(filename, path)
|
self.save_screenshot(filename, path)
|
||||||
|
|
||||||
def export_screenshot(self, *, title: str | None = None) -> str:
|
def export_screenshot(self, *, title: str | None = None) -> str:
|
||||||
"""Export a SVG screenshot of the current screen.
|
"""Export an SVG screenshot of the current screen.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
title (str | None, optional): The title of the exported screenshot or None
|
title (str | None, optional): The title of the exported screenshot or None
|
||||||
@@ -519,7 +519,7 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
path: str = "./",
|
path: str = "./",
|
||||||
time_format: str = "%Y-%m-%d %X %f",
|
time_format: str = "%Y-%m-%d %X %f",
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Save a SVG screenshot of the current screen.
|
"""Save an SVG screenshot of the current screen.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename (str | None, optional): Filename of SVG screenshot, or None to auto-generate
|
filename (str | None, optional): Filename of SVG screenshot, or None to auto-generate
|
||||||
|
|||||||
Reference in New Issue
Block a user