-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss_height.py
More file actions
102 lines (84 loc) · 2.26 KB
/
Copy pathcss_height.py
File metadata and controls
102 lines (84 loc) · 2.26 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import asyncio
from textual import work
from textual.app import App, ComposeResult
from textual.widgets import (
DataTable,
Footer,
Header,
Log,
Static,
TabbedContent,
TabPane,
)
from textual.worker import Worker, WorkerState
from typing_extensions import override
class SubTabContent(Static):
@override
def compose(self) -> ComposeResult:
yield DataTable()
yield Log()
def on_mount(self) -> None:
table = self.query_one(DataTable)
table.add_columns(
"Col 1",
"Col 2",
"Col 3",
)
self.set_interval(1, self._run_command)
@work(exclusive=True)
async def _run_command(self) -> None:
table = self.query_one(DataTable)
table.add_row(
"cell 1",
"cell 2",
"cell 3",
)
table.action_scroll_bottom()
def on_worker_state_changed(self, event: Worker.StateChanged) -> None:
log = self.query_one(Log)
if event.state == WorkerState.PENDING:
log.clear()
log.write_line(f"Worker state changed: {event.state}")
class SubTabs(Static):
@override
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("Sub Tab 1"):
yield SubTabContent()
with TabPane("Sub Tab 2"):
yield SubTabContent()
with TabPane("Sub Tab 3"):
yield SubTabContent()
class MainTabs(Static):
@override
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("Tab 1"):
yield SubTabs()
with TabPane("Tab 2"):
yield SubTabs()
with TabPane("Tab 3"):
yield SubTabs()
class MyApp(App[None]):
CSS = """
SubTabContent {
border: solid $primary;
height: 1fr;
}
DataTable {
border: solid $secondary;
max-height: 75%;
}
Log {
border: solid $secondary;
min-height: 25%;
}
"""
@override
def compose(self) -> ComposeResult:
yield Header()
yield MainTabs()
yield Footer()
if __name__ == "__main__":
app = MyApp()
app.run()