Skip to content

Commit acb23d3

Browse files
authored
Merge branch 'main' into inline-screen-fix
2 parents 1cefc8d + e08c3f9 commit acb23d3

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ 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-
98
## [0.56.0] - Unreleased
109

1110
### Added
@@ -16,6 +15,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1615

1716
- Fixed issue with inline mode and multiple screens https://github.com/Textualize/textual/pull/4393
1817

18+
### Changed
19+
20+
- self.prevent can be used in a widget constructor to prevent messages on mount https://github.com/Textualize/textual/pull/4392
21+
22+
1923
## [0.55.1] - 2024-04-2
2024

2125
### Fixed

src/textual/message_pump.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def __init__(self, parent: MessagePump | None = None) -> None:
144144
"""
145145
self._next_callbacks: list[events.Callback] = []
146146
self._thread_id: int = threading.get_ident()
147+
self._prevented_messages_on_mount = self._prevent_message_types_stack[-1]
147148

148149
@property
149150
def _prevent_message_types_stack(self) -> list[set[type[Message]]]:
@@ -524,7 +525,11 @@ async def _pre_process(self) -> bool:
524525

525526
try:
526527
await self._dispatch_message(events.Compose())
527-
await self._dispatch_message(events.Mount())
528+
if self._prevented_messages_on_mount:
529+
with self.prevent(*self._prevented_messages_on_mount):
530+
await self._dispatch_message(events.Mount())
531+
else:
532+
await self._dispatch_message(events.Mount())
528533
self.check_idle()
529534
self._post_mount()
530535
except Exception as error:

src/textual/widgets/_select.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from dataclasses import dataclass
44
from typing import TYPE_CHECKING, Generic, Iterable, TypeVar, Union
55

6+
import rich.repr
67
from rich.console import RenderableType
78
from rich.text import Text
89

@@ -256,6 +257,7 @@ class Select(Generic[SelectType], Vertical, can_focus=True):
256257
exception.
257258
"""
258259

260+
@rich.repr.auto
259261
class Changed(Message):
260262
"""Posted when the select value was changed.
261263
@@ -274,6 +276,10 @@ def __init__(
274276
self.value = value
275277
"""The value of the Select when it changed."""
276278

279+
def __rich_repr__(self) -> rich.repr.Result:
280+
yield self.select
281+
yield self.value
282+
277283
@property
278284
def control(self) -> Select[SelectType]:
279285
"""The Select that sent the message."""

0 commit comments

Comments
 (0)