Skip to content

Commit

Permalink
Add base class for TabPane messages.
Browse files Browse the repository at this point in the history
Related review comment: #3152 (comment).
  • Loading branch information
rodrigogiraoserrao committed Aug 23, 2023
1 parent 79f8ab0 commit 9ef644c
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/textual/widgets/_tabbed_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ class TabPane(Widget):
"""

@dataclass
class Disabled(Message):
"""Sent when a tab pane is disabled via its reactive `disabled`."""
class TabPaneMessage(Message):
"""Base class for `TabPane` messages."""

tab_pane: TabPane
"""The `TabPane` that was disabled."""
"""The `TabPane` that is he object of this message."""

@property
def control(self) -> TabPane:
Expand All @@ -68,20 +68,12 @@ def control(self) -> TabPane:
return self.tab_pane

@dataclass
class Enabled(Message):
"""Sent when a tab pane is enabled via its reactive `disabled`."""

tab_pane: TabPane
"""The `TabPane` that was enabled."""

@property
def control(self) -> TabPane:
"""The tab pane that is the object of this message.
class Disabled(TabPaneMessage):
"""Sent when a tab pane is disabled via its reactive `disabled`."""

This is an alias for the attribute `tab_pane` and is used by the
[`on`][textual.on] decorator.
"""
return self.tab_pane
@dataclass
class Enabled(TabPaneMessage):
"""Sent when a tab pane is enabled via its reactive `disabled`."""

def __init__(
self,
Expand Down

0 comments on commit 9ef644c

Please sign in to comment.