File size: 1,066 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
from __future__ import annotations

from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import Static, Footer, Header


class JustABox(App):
    BINDINGS = [
        Binding(key="t", action="text_fade_out", description="text-opacity fade out"),
        Binding(key="o,f,w", action="widget_fade_out", description="opacity fade out"),
    ]

    def compose(self) -> ComposeResult:
        yield Header()
        yield Static("Hello, world!", id="box1")
        yield Footer()

    def action_text_fade_out(self) -> None:
        box = self.query_one("#box1")
        self.animator.animate(box.styles, "text_opacity", value=0.0, duration=1)

    def action_widget_fade_out(self) -> None:
        box = self.query_one("#box1")
        self.animator.animate(box.styles, "opacity", value=0.0, duration=1)

    def key_d(self):
        print(self.screen.styles.get_rules())
        print(self.screen.styles.css)


app = JustABox(watch_css=True, css_path="../darren/just_a_box.css")

if __name__ == "__main__":
    app.run()