docs(textual-ui): textual exploration
This commit is contained in:
parent
dc2a19051f
commit
628f3fb7ca
3 changed files with 39 additions and 0 deletions
20
doc/essai_textual.py
Normal file
20
doc/essai_textual.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
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()
|
||||||
18
doc/essai_textual2.py
Normal file
18
doc/essai_textual2.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
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()
|
||||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
textual
|
||||||
Loading…
Reference in a new issue