File size: 1,048 Bytes
2c3c408
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from textual.app import App
from textual.containers import Vertical, Center
from textual.widgets import Static


class CenterApp(App):
    DEFAULT_CSS = """

    #sidebar {
        dock: left;
        width: 32;
        height: 100%;
        border-right: vkey $primary;
    }

    #bottombar {
        dock: bottom;
        height: 12;
        width: 100%;
        border-top: hkey $primary;
    }

    #hello {
        border: wide $primary;
        width: 40;
        height: 16;      
        margin: 2 4;  
    }

    #sidebar.hidden {
       width: 0;
    }

    Static {        
        background: $panel;
        color: $text;
        content-align: center middle;
    }
    
    """

    def on_mount(self) -> None:
        self.bind("t", "toggle_class('#sidebar', 'hidden')")

    def compose(self):
        yield Static("Sidebar", id="sidebar")
        yield Vertical(
            Static("Bottom bar", id="bottombar"),
            Center(
                Static("Hello World!", id="hello"),
            ),
        )


app = CenterApp()