Add 'control' alias to Tabs messages. (#2483)

* Add 'control' alias to Tabs messages.

Related issues: #2478.

* Changelog.
This commit is contained in:
Rodrigo Girão Serrão
2023-05-08 11:15:19 +01:00
committed by GitHub
parent 7db7139bb8
commit 9c9829eb0f
2 changed files with 19 additions and 2 deletions

View File

@@ -18,12 +18,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The DataTable cursor is now scrolled into view when the cursor coordinate is changed programmatically https://github.com/Textualize/textual/issues/2459
- run_worker exclusive parameter is now `False` by default https://github.com/Textualize/textual/pull/2470
- Added `always_update` as an optional argument for `reactive.var`
- Made Binding description default to empty string, which is equivalent to show=False https://github.com/Textualize/textual/pull/2501
- Modified Message to allow it to be used as a dataclass https://github.com/Textualize/textual/pull/2501
### Added
- Property `control` as alias for attribute `tabs` in `Tabs` messages https://github.com/Textualize/textual/pull/2483
- Experimental: Added "overlay" rule https://github.com/Textualize/textual/pull/2501
- Experimental: Added "constrain" rule https://github.com/Textualize/textual/pull/2501
- Added textual.widgets.Select https://github.com/Textualize/textual/pull/2501
@@ -35,7 +35,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `TreeNode.remove_children` https://github.com/Textualize/textual/pull/2510
- Added `TreeNode.remove` https://github.com/Textualize/textual/pull/2510
## [0.23.0] - 2023-05-03
### Fixed

View File

@@ -194,6 +194,15 @@ class Tabs(Widget, can_focus=True):
self.tab = tab
super().__init__()
@property
def control(self) -> Tabs:
"""The tabs widget containing the tab that was activated.
This is an alias for [`TabActivated.tabs`][textual.widgets.Tabs.TabActivated.tabs]
which is used by the [`on`][textual.on] decorator.
"""
return self.tabs
def __rich_repr__(self) -> rich.repr.Result:
yield self.tabs
yield self.tab
@@ -213,6 +222,15 @@ class Tabs(Widget, can_focus=True):
self.tabs = tabs
super().__init__()
@property
def control(self) -> Tabs:
"""The tabs widget which was cleared.
This is an alias for [`Cleared.tabs`][textual.widgets.Tabs.Cleared] which
is used by the [`on`][textual.on] decorator.
"""
return self.tabs
def __rich_repr__(self) -> rich.repr.Result:
yield self.tabs