mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
48 lines
884 B
Python
48 lines
884 B
Python
from itertools import cycle
|
|
|
|
from textual.app import App, ComposeResult
|
|
from textual.widgets import Static
|
|
|
|
hellos = cycle(
|
|
[
|
|
"Hola",
|
|
"Bonjour",
|
|
"Guten tag",
|
|
"Salve",
|
|
"Nǐn hǎo",
|
|
"Olá",
|
|
"Asalaam alaikum",
|
|
"Konnichiwa",
|
|
"Anyoung haseyo",
|
|
"Zdravstvuyte",
|
|
"Hello",
|
|
]
|
|
)
|
|
|
|
|
|
class Hello(Static):
|
|
"""Display a greeting."""
|
|
|
|
def on_mount(self) -> None:
|
|
self.next_word()
|
|
|
|
def on_click(self) -> None:
|
|
self.next_word()
|
|
|
|
def next_word(self) -> None:
|
|
"""Get a new hello and update the content area."""
|
|
hello = next(hellos)
|
|
self.update(f"{hello}, [b]World[/b]!")
|
|
|
|
|
|
class CustomApp(App):
|
|
CSS_PATH = "hello03.tcss"
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Hello()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = CustomApp()
|
|
app.run()
|