|
| 1 | +--- |
| 2 | +draft: false |
| 3 | +date: 2023-03-29 |
| 4 | +categories: |
| 5 | + - Release |
| 6 | +title: "Textual 0.17.0 adds translucent screens and Option List" |
| 7 | +authors: |
| 8 | + - willmcgugan |
| 9 | +--- |
| 10 | + |
| 11 | +# Textual 0.17.0 adds translucent screens and Option List |
| 12 | + |
| 13 | +This is a surprisingly large release, given it has been just 7 days since the last version (and we were down a developer for most of that time). |
| 14 | + |
| 15 | +What's new in this release? |
| 16 | + |
| 17 | +<!-- more --> |
| 18 | + |
| 19 | +There are two new notable features I want to cover. The first is a compositor effect. |
| 20 | + |
| 21 | +## Translucent screens |
| 22 | + |
| 23 | +Textual has a concept of "screens" which you can think of as independent UI modes, each with their own user interface and logic. |
| 24 | +The App class keeps a stack of these screens so you can switch to a new screen and later return to the previous screen. |
| 25 | + |
| 26 | +!!! tip inline end "Screens" |
| 27 | + |
| 28 | + See the [guide](../../guide/screens.md) to learn more about the screens API. |
| 29 | + |
| 30 | + <a href="/guide/screens"> |
| 31 | + <div class="excalidraw"> |
| 32 | + --8<-- "docs/images/screens/pop_screen.excalidraw.svg" |
| 33 | + </div> |
| 34 | + </a> |
| 35 | + |
| 36 | +Screens can be used to build modal dialogs by *pushing* a screen with controls / buttons, and *popping* the screen when the user has finished with it. |
| 37 | +The problem with this approach is that there was nothing to indicate to the user that the original screen was still there, and could be returned to. |
| 38 | + |
| 39 | +In this release we have added alpha support to the Screen's background color which allows the screen underneath to show through, typically blended with a little color. |
| 40 | +Applying this to a screen makes it clear than the user can return to the previous screen when they have finished interacting with the modal. |
| 41 | + |
| 42 | +Here's how you can enable this effect with CSS: |
| 43 | + |
| 44 | +```sass hl_lines="3" |
| 45 | +DialogScreen { |
| 46 | + align: center middle; |
| 47 | + background: $primary 30%; |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +Setting the background to `$primary` will make the background blue (with the default theme). |
| 52 | +The addition of `30%` sets the alpha so that it will be blended with the background. |
| 53 | +Here's the kind of effect this creates: |
| 54 | + |
| 55 | +<div> |
| 56 | +--8<-- "docs/blog/images/transparent_background.svg" |
| 57 | +</div> |
| 58 | + |
| 59 | +There are 4 screens in the above screenshot, one for the base screen and one for each of the three dialogs. |
| 60 | +Note how each screen modifies the color of the screen below, but leaves everything visible. |
| 61 | + |
| 62 | +See the [docs on screen opacity](../../guide/screens.md#screen-opacity) if you want to add this to your apps. |
| 63 | + |
| 64 | +## Option list |
| 65 | + |
| 66 | +Textual has had a [ListView](../../widgets/list_view.md) widget for a while, which is an excellent way of navigating a list of items (actually other widgets). In this release we've added an [OptionList](../../widgets/option_list.md) which is similar in appearance, but uses the [line api](../../guide/widgets.md#line-api) under the hood. The Line API makes it more efficient when you approach thousands of items. |
| 67 | + |
| 68 | +```{.textual path="docs/examples/widgets/option_list_strings.py"} |
| 69 | +``` |
| 70 | + |
| 71 | +The Options List accepts [Rich](https://github.com/Textualize/rich/) *renderable*, which means that anything Rich can render may be displayed in a list. Here's an Option List of tables: |
| 72 | + |
| 73 | +```{.textual path="docs/examples/widgets/option_list_tables.py" columns="100" lines="32"} |
| 74 | +``` |
| 75 | + |
| 76 | +We plan to build on the `OptionList` widget to implement drop-downs, menus, check lists, etc. |
| 77 | +But it is still very useful as it is, and you can add it to apps now. |
| 78 | + |
| 79 | +## What else? |
| 80 | + |
| 81 | +There are a number of fixes regarding refreshing in this release. If you had issues with parts of the screen not updating, the new version should resolve it. |
| 82 | + |
| 83 | +There's also a new logging handler, and a "thick" border type. |
| 84 | + |
| 85 | +See [release notes](https://github.com/Textualize/textual/releases/tag/v0.17.0) for the full details. |
| 86 | + |
| 87 | + |
| 88 | +## Next week |
| 89 | + |
| 90 | +Next week we plan to take a break from building Textual to *building apps* with Textual. |
| 91 | +We do this now and again to give us an opportunity to step back and understand things from the perspective of a developer using Textual. |
| 92 | +We will hopefully have something interesting to show from the exercise, and new Open Source apps to share. |
| 93 | + |
| 94 | +## Join us |
| 95 | + |
| 96 | +If you want to talk about this update or anything else Textual related, join us on our [Discord server](https://discord.gg/Enf6Z3qhVr). |
0 commit comments