18 lines
558 B
Python
18 lines
558 B
Python
from textual.app import App, ComposeResult
|
|
from textual.widgets import Button, Label
|
|
from textual.containers import Vertical
|
|
|
|
class ButtonApp(App):
|
|
def compose(self) -> ComposeResult:
|
|
yield Vertical(
|
|
Button("Cliquez-moi !", id="mon-bouton"),
|
|
Label("", id="message")
|
|
)
|
|
|
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
if event.button.id == "mon-bouton":
|
|
self.query_one("#message", Label).update("Bouton cliqué !")
|
|
|
|
if __name__ == "__main__":
|
|
app = ButtonApp()
|
|
app.run()
|