Skip to content

Commit 2cd8295

Browse files
authored
Release0170 (#2165)
* blog post * blog post * options list * snapshot * words * fix flicker
1 parent 0be094c commit 2cd8295

File tree

11 files changed

+993
-558
lines changed

11 files changed

+993
-558
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## Unreleased
8+
## [0.17.0] - 2023-03-29
99

1010
### Fixed
1111

@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3333
- Screens with alpha in their background color will now blend with the background. https://github.com/Textualize/textual/pull/2139
3434
- Added "thick" border style. https://github.com/Textualize/textual/pull/2139
3535
- message_pump.app will now set the active app if it is not already set.
36+
- DataTable now has max height set to 100vh
3637

3738
### Added
3839

docs/blog/images/transparent_background.svg

Lines changed: 307 additions & 0 deletions
Loading

docs/blog/posts/release0-17-0.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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).

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "textual"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
homepage = "https://github.com/Textualize/textual"
55
description = "Modern Text User Interface framework"
66
authors = ["Will McGugan <[email protected]>"]

src/textual/_compositor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ def render_partial_update(self) -> ChopsUpdate | None:
849849
"""
850850
screen_region = self.size.region
851851
update_regions = self._dirty_regions.copy()
852+
self._dirty_regions.clear()
852853
if update_regions:
853854
# Create a crop region that surrounds all updates.
854855
crop = Region.from_union(update_regions).intersection(screen_region)

src/textual/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ async def invoke_ready_callback() -> None:
15991599
try:
16001600
await self._dispatch_message(events.Compose())
16011601
await self._dispatch_message(events.Mount())
1602+
self.check_idle()
16021603
finally:
16031604
self._mounted_event.set()
16041605

src/textual/message_pump.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ async def _pre_process(self) -> None:
437437
try:
438438
await self._dispatch_message(events.Compose())
439439
await self._dispatch_message(events.Mount())
440+
self.check_idle()
440441
self._post_mount()
441442
except Exception as error:
442443
self.app._handle_exception(error)

src/textual/screen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ async def _on_idle(self, event: events.Idle) -> None:
382382
self._repaint_required = False
383383

384384
if self._dirty_widgets:
385-
self._on_timer_update()
386385
self.update_timer.resume()
387386

388387
# The Screen is idle - a good opportunity to invoke the scheduled callbacks

src/textual/widgets/_data_table.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
247247
background: $surface ;
248248
color: $text;
249249
height: auto;
250+
max-height: 100vh
250251
}
251252
DataTable > .datatable--header {
252253
text-style: bold;

src/textual/widgets/_option_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class OptionList(ScrollView, can_focus=True):
176176
}
177177
178178
OptionList > .option-list--separator {
179-
color: $text-muted;
179+
color: $foreground 15%;
180180
}
181181
182182
OptionList > .option-list--option-highlighted {

0 commit comments

Comments
 (0)