update blog

This commit is contained in:
Will McGugan
2023-02-24 17:07:51 +00:00
parent e3976155fd
commit 01a4ed97e1

View File

@@ -66,7 +66,7 @@ for color_name in ColorSystem.COLOR_NAMES:
yield ColorBar("$text-disabled", classes="disabled") yield ColorBar("$text-disabled", classes="disabled")
``` ```
The context manager approach generally results in fewer lines of code, and presents attributes on the same line as containers themselves. Additionally, adding widgets to a container can be as simple is indenting them, The context manager approach generally results in fewer lines of code, and presents attributes on the same line as containers themselves. Additionally, adding widgets to a container can be as simple is indenting them.
You can still construct widgets and containers with positional arguments, but this new syntax is preferred. It's not documented yet, but you can start using it now. We will be updating our examples in the next few weeks. You can still construct widgets and containers with positional arguments, but this new syntax is preferred. It's not documented yet, but you can start using it now. We will be updating our examples in the next few weeks.
@@ -76,7 +76,7 @@ Textual is smart about performing updates to the screen. When you make a change
Although this works very well, it is possible to introduce a little flicker if you make changes across multiple widgets. And especially if you add or remove many widgets at once. To combat this we have added a [batch_update][textual.app.App.batch_update] context manager which tells Textual to disable screen updates until the end of the with block. Although this works very well, it is possible to introduce a little flicker if you make changes across multiple widgets. And especially if you add or remove many widgets at once. To combat this we have added a [batch_update][textual.app.App.batch_update] context manager which tells Textual to disable screen updates until the end of the with block.
The new [Markdown](./release0-11-0.md) uses this context manager when it updates its content. Here's the code: The new [Markdown](./release0-11-0.md) widget uses this context manager when it updates its content. Here's the code:
```python ```python
with self.app.batch_update(): with self.app.batch_update():
@@ -84,12 +84,16 @@ with self.app.batch_update():
await self.mount_all(output) await self.mount_all(output)
``` ```
Without the batch update there are a few frames where the old markdown blocks are removed and the new blocks are added, which the user will perceive as a brief flicker. Without the batch update there are a few frames where the old markdown blocks are removed and the new blocks are added (which would be perceived as a brief flicker). With the update, the update appears instant.
## Disabled widgets ## Disabled widgets
A few widgets (such as [Button](./../../widgets/button.md) had a `disabled` attribute which would fade the widget a little and make it unselectable. We've extended this to all widgets. Although it is particularly applicable to input controls, anything may be disabled. Disabling a container makes its children disabled, so you could use this for disabling a form, for example. A few widgets (such as [Button](./../../widgets/button.md) had a `disabled` attribute which would fade the widget a little and make it unselectable. We've extended this to all widgets. Although it is particularly applicable to input controls, anything may be disabled. Disabling a container makes its children disabled, so you could use this for disabling a form, for example.
!!! tip
Disabled widgets may be styled with the `:disabled` CSS pseudo-selector.
## Preventing messages ## Preventing messages
Also in this release is another context manager, which will disable specified Message types. This doesn't come up as a requirement very often, but it can be very useful when it does. This one is documented, see [Preventing events](./../../guide/events.md#preventing-messages) for details. Also in this release is another context manager, which will disable specified Message types. This doesn't come up as a requirement very often, but it can be very useful when it does. This one is documented, see [Preventing events](./../../guide/events.md#preventing-messages) for details.