From 0a7b7dd1fdecfb7d86c66489a80ced1dc288a493 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 15 Oct 2022 18:04:17 +0100 Subject: [PATCH 1/6] Remove trailing whitespace --- docs/guide/reactivity.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/guide/reactivity.md b/docs/guide/reactivity.md index 5b4cf2af7..1951eb237 100644 --- a/docs/guide/reactivity.md +++ b/docs/guide/reactivity.md @@ -33,7 +33,7 @@ The `reactive` constructor accepts a default value as the first positional argum !!! information - Textual uses Python's _descriptor protocol_ to create reactive attributes, which is the same protocol used by the builtin `property` decorator. + Textual uses Python's _descriptor protocol_ to create reactive attributes, which is the same protocol used by the builtin `property` decorator. You can get and set these attributes in the same way as if you had assigned them in a `__init__` method. For instance `self.name = "Jessica"`, `self.count += 1`, or `print(self.is_cool)`. @@ -81,7 +81,7 @@ Let's look at an example which illustrates this. In the following app, the value === "refresh01.css" - ```sass + ```sass --8<-- "docs/examples/guide/reactivity/refresh01.css" ``` @@ -121,7 +121,7 @@ The following example modifies "refresh01.py" so that the greeting has an automa --8<-- "docs/examples/guide/reactivity/refresh02.py" ``` - 1. This attribute will update the layout when changed. + 1. This attribute will update the layout when changed. === "refresh02.css" @@ -152,7 +152,7 @@ A common use for this is to restrict numbers to a given range. The following exa === "validate01.css" - ```sass + ```sass --8<-- "docs/examples/guide/reactivity/validate01.css" ``` @@ -181,7 +181,7 @@ The follow app will display any color you type in to the input. Try it with a va === "watch01.css" - ```sass + ```sass --8<-- "docs/examples/guide/reactivity/watch01.css" ``` @@ -196,7 +196,7 @@ The color is parsed in `on_input_submitted` and assigned to `self.color`. Becaus Compute methods are the final superpower offered by the `reactive` descriptor. Textual runs compute methods to calculate the value of a reactive attribute. Compute methods begin with `compute_` followed by the name of the reactive value. -You could be forgiven in thinking this sounds a lot like Python's property decorator. The difference is that Textual will cache the value of compute methods, and update them when any other reactive attribute changes. +You could be forgiven in thinking this sounds a lot like Python's property decorator. The difference is that Textual will cache the value of compute methods, and update them when any other reactive attribute changes. The following example uses a computed attribute. It displays three inputs for the each color component (red, green, and blue). If you enter numbers in to these inputs, the background color of another widget changes. @@ -211,7 +211,7 @@ The following example uses a computed attribute. It displays three inputs for th === "computed01.css" - ```sass + ```sass --8<-- "docs/examples/guide/reactivity/computed01.css" ``` From 306580ec93c34e0736ef6dab24f996f80bf61063 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 15 Oct 2022 18:07:24 +0100 Subject: [PATCH 2/6] 'a' -> 'an' This one could go either way, I guess. If most folk read __init__ like I do, simply as the word "init" then this is needed; likewise if they say the underscore, on the other hand if folk tend to go with dunder-init...) I may recant this depending on the result of this: https://twitter.com/davepdotorg/status/1581331978049052672 --- docs/guide/reactivity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/reactivity.md b/docs/guide/reactivity.md index 1951eb237..075fcbf94 100644 --- a/docs/guide/reactivity.md +++ b/docs/guide/reactivity.md @@ -35,7 +35,7 @@ The `reactive` constructor accepts a default value as the first positional argum Textual uses Python's _descriptor protocol_ to create reactive attributes, which is the same protocol used by the builtin `property` decorator. -You can get and set these attributes in the same way as if you had assigned them in a `__init__` method. For instance `self.name = "Jessica"`, `self.count += 1`, or `print(self.is_cool)`. +You can get and set these attributes in the same way as if you had assigned them in an `__init__` method. For instance `self.name = "Jessica"`, `self.count += 1`, or `print(self.is_cool)`. ### Dynamic defaults From c159b434b55026e8c16ceee05e25ff517d39fcdb Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 15 Oct 2022 18:18:29 +0100 Subject: [PATCH 3/6] Singular attribute to attributes If there's multiple... --- docs/guide/reactivity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/reactivity.md b/docs/guide/reactivity.md index 075fcbf94..a99998a96 100644 --- a/docs/guide/reactivity.md +++ b/docs/guide/reactivity.md @@ -69,7 +69,7 @@ The first superpower we will look at is "smart refresh". When you modify a react !!! information - If you modify multiple reactive attribute, Textual will only do a single refresh to minimize updates. + If you modify multiple reactive attributes, Textual will only do a single refresh to minimize updates. Let's look at an example which illustrates this. In the following app, the value of an input is used to update a "Hello, World!" type greeting. From 1805dd7abba27c1ba44c8bd57907a6c324f13921 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 15 Oct 2022 18:23:27 +0100 Subject: [PATCH 4/6] 'follow' -> 'following' --- docs/guide/reactivity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/reactivity.md b/docs/guide/reactivity.md index a99998a96..f15039550 100644 --- a/docs/guide/reactivity.md +++ b/docs/guide/reactivity.md @@ -167,7 +167,7 @@ If you click the buttons in the above example it will show the current count. Wh Watch methods are another superpower. Textual will call watch methods when reactive attributes are modified. Watch methods begin with `watch_` followed by the name of the attribute. If the watch method accepts a positional argument, it will be called with the new assigned value. If the watch method accepts *two* positional arguments, it will be called with both the *old* value and the *new* value. -The follow app will display any color you type in to the input. Try it with a valid color in Textual CSS. For example `"darkorchid"` or `"#52de44". +The following app will display any color you type in to the input. Try it with a valid color in Textual CSS. For example `"darkorchid"` or `"#52de44". === "watch01.py" From 09fe0077edb4dbffba730884b6b296a0280810fe Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 15 Oct 2022 18:23:52 +0100 Subject: [PATCH 5/6] Add missing code markup marker --- docs/guide/reactivity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/reactivity.md b/docs/guide/reactivity.md index f15039550..6001aa647 100644 --- a/docs/guide/reactivity.md +++ b/docs/guide/reactivity.md @@ -167,7 +167,7 @@ If you click the buttons in the above example it will show the current count. Wh Watch methods are another superpower. Textual will call watch methods when reactive attributes are modified. Watch methods begin with `watch_` followed by the name of the attribute. If the watch method accepts a positional argument, it will be called with the new assigned value. If the watch method accepts *two* positional arguments, it will be called with both the *old* value and the *new* value. -The following app will display any color you type in to the input. Try it with a valid color in Textual CSS. For example `"darkorchid"` or `"#52de44". +The following app will display any color you type in to the input. Try it with a valid color in Textual CSS. For example `"darkorchid"` or `"#52de44"`. === "watch01.py" From 67d722507b19d2f589590c8ba9e9bf4510a3b946 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 15 Oct 2022 18:25:59 +0100 Subject: [PATCH 6/6] Remove unnecessary 'the' --- docs/guide/reactivity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/reactivity.md b/docs/guide/reactivity.md index 6001aa647..86a7d7d90 100644 --- a/docs/guide/reactivity.md +++ b/docs/guide/reactivity.md @@ -198,7 +198,7 @@ Compute methods are the final superpower offered by the `reactive` descriptor. T You could be forgiven in thinking this sounds a lot like Python's property decorator. The difference is that Textual will cache the value of compute methods, and update them when any other reactive attribute changes. -The following example uses a computed attribute. It displays three inputs for the each color component (red, green, and blue). If you enter numbers in to these inputs, the background color of another widget changes. +The following example uses a computed attribute. It displays three inputs for each color component (red, green, and blue). If you enter numbers in to these inputs, the background color of another widget changes. === "computed01.py"