How do I create an interactive button? #28
Unanswered
ethansocal
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Documentation is coming, but the basic principle is you have a widget with an on_click method and you emit a message. from textual.message import Message
class ButtonPressed(Message, bubble=True):
pass
class Button(Widget):
async def on_click(self, event: events.Click) -> None:
await self.emit(ButtonPressed(self)) Then in the parent view / app you can catch the message with the following: async def message_button_event(self, message: ButtonPressed) -> None:
# button handler |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to create a button that when pressed, triggers an event?
Beta Was this translation helpful? Give feedback.
All reactions