Skip to content

Commit

Permalink
Fix TabbedContent __init__ signature. (#2497)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigogiraoserrao authored May 8, 2023
1 parent 483aa54 commit 1e2f632
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 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`
- `TabbedContent` now takes kwargs `id`, `name`, `classes`, and `disabled`, upon initialization, like other widgets https://github.com/Textualize/textual/pull/2497


### Added
Expand Down
16 changes: 14 additions & 2 deletions src/textual/widgets/_tabbed_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,29 @@ def __rich_repr__(self) -> Result:
yield self.tabbed_content
yield self.tab

def __init__(self, *titles: TextType, initial: str = "") -> None:
def __init__(
self,
*titles: TextType,
initial: str = "",
name: str | None = None,
id: str | None = None,
classes: str | None = None,
disabled: bool = False,
):
"""Initialize a TabbedContent widgets.
Args:
*titles: Positional argument will be used as title.
initial: The id of the initial tab, or empty string to select the first tab.
name: The name of the button.
id: The ID of the button in the DOM.
classes: The CSS classes of the button.
disabled: Whether the button is disabled or not.
"""
self.titles = [self.render_str(title) for title in titles]
self._tab_content: list[Widget] = []
self._initial = initial
super().__init__()
super().__init__(name=name, id=id, classes=classes, disabled=disabled)

def validate_active(self, active: str) -> str:
"""It doesn't make sense for `active` to be an empty string.
Expand Down

0 comments on commit 1e2f632

Please sign in to comment.