mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
border classvars (#3097)
* border classvars * changelog * copy * remove whitespace * copy
This commit is contained in:
12
docs/examples/guide/widgets/hello06.css
Normal file
12
docs/examples/guide/widgets/hello06.css
Normal file
@@ -0,0 +1,12 @@
|
||||
Screen {
|
||||
align: center middle;
|
||||
}
|
||||
|
||||
Hello {
|
||||
width: 40;
|
||||
height: 9;
|
||||
padding: 1 2;
|
||||
background: $panel;
|
||||
border: $secondary tall;
|
||||
content-align: center middle;
|
||||
}
|
||||
47
docs/examples/guide/widgets/hello06.py
Normal file
47
docs/examples/guide/widgets/hello06.py
Normal file
@@ -0,0 +1,47 @@
|
||||
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."""
|
||||
|
||||
BORDER_TITLE = "Hello Widget" # (1)!
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.action_next_word()
|
||||
self.border_subtitle = "Click for next hello" # (2)!
|
||||
|
||||
def action_next_word(self) -> None:
|
||||
"""Get a new hello and update the content area."""
|
||||
hello = next(hellos)
|
||||
self.update(f"[@click='next_word']{hello}[/], [b]World[/b]!")
|
||||
|
||||
|
||||
class CustomApp(App):
|
||||
CSS_PATH = "hello05.css"
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Hello()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = CustomApp()
|
||||
app.run()
|
||||
Reference in New Issue
Block a user