-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_sidebar_layout.py
60 lines (50 loc) · 1.75 KB
/
demo_sidebar_layout.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pathlib
from textual.app import App, ComposeResult
from textual.containers import Grid, Horizontal, Vertical
from textual.widgets import Button, Checkbox, Input, Label, Static, TextArea
class SidebarApp(App[None]):
CSS = """
#sidebar {
background: $panel;
border: vkey $primary;
width: 35;
height: auto;
& #sidebar_label {
width: 100%;
text-align: center;
text-style: bold;
margin-bottom: 1;
}
}
#settings {
height: auto;
grid-size: 2;
grid-columns: 5 2fr;
& Label {
height: 100%;
width: 100%;
content-align: right middle;
}
}
#buttons {
align: center middle;
}
"""
def compose(self) -> ComposeResult:
with Horizontal():
with Vertical(id="sidebar"):
yield Label("Sidebar", id="sidebar_label")
with Grid(id="settings"):
yield Label("Name:")
yield Input(pathlib.Path(__file__).name)
yield Label()
yield Checkbox(label="BasicFeature", value=True)
yield Label()
yield Checkbox(label="ProFeature", value=False)
with Horizontal(id="buttons"):
yield Button("Reset Settings", id="reset_button")
yield Static("Here you can change some settings. It is a nice sidebar!")
yield TextArea(pathlib.Path(__file__).read_text(), language="python")
def on_mount(self) -> None:
self.query_one("TextArea").focus()
SidebarApp().run()