-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expand file tree
/
Copy pathstatic_and_label.py
More file actions
32 lines (27 loc) · 953 Bytes
/
static_and_label.py
File metadata and controls
32 lines (27 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from textual.app import App
from textual.widgets import Label, Static
class StaticAndLabelApp(App):
def compose(self):
self.static = Static(
"I am a [bold red]Static[/bold red] widget!",
)
yield self.static
self.label = Label(
"I am a [yellow italic]Label[/yellow italic] widget!",
)
yield self.label
def on_mount(self):
# Styling the static
self.static.styles.background = "blue"
self.static.styles.border = ("solid", "white")
self.static.styles.text_align = "center"
self.static.styles.padding = 1, 1
self.static.styles.margin = 4, 4
# Styling the label
self.label.styles.background = "darkgreen"
self.label.styles.border = ("double", "red")
self.label.styles.padding = 1, 1
self.label.styles.margin = 2, 4
if __name__ == "__main__":
app = StaticAndLabelApp()
app.run()