Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up some Button documentation #1917

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api/button.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
::: textual.widgets.Button
::: textual.widgets._button.ButtonVariant
::: textual.widgets._button.InvalidButtonVariant
10 changes: 9 additions & 1 deletion src/textual/widgets/_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
from ..widgets import Static

ButtonVariant = Literal["default", "primary", "success", "warning", "error"]
"""The names of the valid button variants.

These are the variants that can be used with a [Button][textual.widgets.Button].
"""

_VALID_BUTTON_VARIANTS = {"default", "primary", "success", "warning", "error"}


class InvalidButtonVariant(Exception):
pass
"""Exception raised if an invalid button variant is used."""


class Button(Static, can_focus=True):
Expand Down Expand Up @@ -262,6 +267,7 @@ def success(
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.

Returns:
A Button widget of the 'success' variant.
Expand Down Expand Up @@ -293,6 +299,7 @@ def warning(
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.

Returns:
A Button widget of the 'warning' variant.
Expand Down Expand Up @@ -324,6 +331,7 @@ def error(
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.

Returns:
A Button widget of the 'error' variant.
Expand Down