Files
textual/docs/examples/app/question02.py
Will McGugan 54539a90d1 refine compose
2022-09-05 11:02:37 +01:00

21 lines
536 B
Python

from textual.app import App, ComposeResult
from textual.widgets import Static, Button
class QuestionApp(App[str]):
def compose(self) -> ComposeResult:
yield Static("Do you love Textual?")
yes = yield Button("Yes", id="yes")
yes.variant = "primary"
no = yield Button("No", id="no")
no.variant = "error"
def on_button_pressed(self, event: Button.Pressed) -> None:
self.exit(event.button.id)
app = QuestionApp()
if __name__ == "__main__":
reply = app.run()
print(reply)