21 lines
556 B
Python
21 lines
556 B
Python
|
|
from textual.app import App, ComposeResult
|
||
|
|
from textual.widgets import Label
|
||
|
|
from textual.containers import Center
|
||
|
|
from textual.events import Key
|
||
|
|
|
||
|
|
class HelloApp(App):
|
||
|
|
"""Une application Textual simple."""
|
||
|
|
|
||
|
|
def compose(self) -> ComposeResult:
|
||
|
|
# Définir les widgets de l'application
|
||
|
|
yield Center(Label("Hello, World!"))
|
||
|
|
|
||
|
|
def on_key(self, event: Key) -> None:
|
||
|
|
# Quitter l'application si on appuie sur 'q'
|
||
|
|
if event.key == "q":
|
||
|
|
self.exit()
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
app = HelloApp()
|
||
|
|
app.run()
|