more introduction docs

This commit is contained in:
Will McGugan
2022-08-20 10:38:00 +01:00
parent 1a2997aa73
commit 47a3536172
6 changed files with 179 additions and 14 deletions

View File

@@ -28,6 +28,6 @@ class StopwatchApp(App):
self.dark = not self.dark
app = StopwatchApp(css_path="stopwatch02.css")
app = StopwatchApp()
if __name__ == "__main__":
app.run()

View File

@@ -0,0 +1,30 @@
Stopwatch {
layout: horizontal;
background: $panel-darken-1;
height: 5;
padding: 1;
margin: 1;
}
TimeDisplay {
content-align: center middle;
opacity: 60%;
height: 3;
}
Button {
width: 16;
}
#start {
dock: left;
}
#stop {
dock: left;
display: none;
}
#reset {
dock: right;
}

View File

@@ -0,0 +1,33 @@
from textual.app import App, ComposeResult
from textual.layout import Container
from textual.widgets import Button, Header, Footer, Static
class TimeDisplay(Static):
pass
class Stopwatch(Static):
def compose(self) -> ComposeResult:
yield Button("Start", id="start", variant="success")
yield Button("Stop", id="stop", variant="error")
yield Button("Reset", id="reset")
yield TimeDisplay("00:00:00.00")
class StopwatchApp(App):
def compose(self):
yield Header()
yield Footer()
yield Container(Stopwatch(), Stopwatch(), Stopwatch())
def on_load(self):
self.bind("d", "toggle_dark", description="Dark mode")
def action_toggle_dark(self):
self.dark = not self.dark
app = StopwatchApp(css_path="stopwatch03.css")
if __name__ == "__main__":
app.run()