-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathcontent_switcher.py
More file actions
60 lines (49 loc) · 1.59 KB
/
content_switcher.py
File metadata and controls
60 lines (49 loc) · 1.59 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
from textual.app import ComposeResult
from textual.containers import VerticalScroll, Container, Horizontal
from textual.widgets import Button, ContentSwitcher, DataTable, Markdown
MARKDOWN_EXAMPLE = """# Three Flavours Cornetto
The Three Flavours Cornetto trilogy is an anthology series of British
comedic genre films directed by Edgar Wright.
## Shaun of the Dead
| Flavour | UK Release Date | Director |
| -- | -- | -- |
| Strawberry | 2004-04-09 | Edgar Wright |
## Hot Fuzz
| Flavour | UK Release Date | Director |
| -- | -- | -- |
| Classico | 2007-02-17 | Edgar Wright |
## The World's End
| Flavour | UK Release Date | Director |
| -- | -- | -- |
| Mint | 2013-07-19 | Edgar Wright |
"""
def content_switcher_example(id: str) -> ComposeResult:
table: DataTable = DataTable(id="data-table")
table.add_columns("Book", "Year")
table.add_rows(
[
(title.ljust(35), year)
for title, year in (
("Dune", 1965),
("Dune Messiah", 1969),
("Children of Dune", 1976),
("God Emperor of Dune", 1981),
("Heretics of Dune", 1984),
("Chapterhouse: Dune", 1985),
)
]
)
yield Container(
Horizontal(
Button("DataTable", id="data-table"),
Button("Markdown", id="markdown"),
id="buttons",
),
ContentSwitcher(
table,
VerticalScroll(Markdown(MARKDOWN_EXAMPLE), id="markdown"),
initial="data-table",
id="content-switcher-example",
),
id=id,
)