Skip to content

Button

Button is a card with nothing but a title and action buttons.

import dachshund
from dachshund.widgets import Button


@dachshund.action("ban", label="Ban", confirm=True)
def ban(ctx, user_id: str) -> None: ...


with dachshund.row():
    dachshund.add(
        Button("ban", actions=["ban"], action_args={"ban": {"user_id": "42"}})
    )

dachshund.widgets.button.button.Button dataclass

Button(name, *, source='', title=None, actions=list(), action_args=dict())

Bases: Widget

A card with nothing but a title and action buttons.

Example

@dachshund.action("ban", label="Ban", confirm=True)
def ban(ctx, user_id: str) -> None: ...


with dachshund.row():
    dachshund.add(
        Button(
            "ban",
            title="Ban a user",
            actions=["ban"],
            action_args={"ban": {"user_id": "42"}},
        )
    )

Options

  • actions (list[str]) - The actions shown as buttons. Defaults to [].
  • action_args (dict[str, dict]) - The arguments each action is called with, by action name. Defaults to {}.

A button has no event or row behind it, so action_args is the only way to pass an action arguments.

type class-attribute

type = 'button'

op class-attribute

op = 'replace'

render

render(events)

Nothing to show, the card is its actions.

Source code in dachshund/widgets/button/button.py
43
44
45
def render(self, events: Sequence[Event]) -> dict[str, Any]:
    """Nothing to show, the card is its actions."""
    return {}

update

update(event)

Nothing ever changes.

Source code in dachshund/widgets/button/button.py
47
48
49
def update(self, event: Event) -> dict[str, Any] | None:
    """Nothing ever changes."""
    return None