renamed introduction to tutorial

This commit is contained in:
Will McGugan
2022-09-05 21:30:29 +01:00
parent 54539a90d1
commit e7d57a4aa2
28 changed files with 182 additions and 67 deletions

View File

@@ -0,0 +1,17 @@
Screen {
layout: table;
table-size: 2;
table-gutter: 2;
padding: 2;
}
#question {
width: 100%;
height: 100%;
column-span: 2;
content-align: center bottom;
text-style: bold;
}
Button {
width: 100%;
}

View File

@@ -4,17 +4,15 @@ from textual.widgets import Static, Button
class QuestionApp(App[str]):
def compose(self) -> ComposeResult:
yield Static("Do you love Textual?")
yes = yield Button("Yes", id="yes")
yes.variant = "primary"
no = yield Button("No", id="no")
no.variant = "error"
yield Static("Do you love Textual?", id="question")
yield Button("Yes", id="yes", variant="primary")
yield Button("No", id="no", variant="error")
def on_button_pressed(self, event: Button.Pressed) -> None:
self.exit(event.button.id)
app = QuestionApp()
app = QuestionApp(css_path="question02.css")
if __name__ == "__main__":
reply = app.run()
print(reply)

View File

@@ -0,0 +1,38 @@
from textual.app import App, ComposeResult
from textual.widgets import Static, Button
class QuestionApp(App[str]):
CSS = """
Screen {
layout: table;
table-size: 2;
table-gutter: 2;
padding: 2;
}
#question {
width: 100%;
height: 100%;
column-span: 2;
content-align: center bottom;
text-style: bold;
}
Button {
width: 100%;
}
"""
def compose(self) -> ComposeResult:
yield Static("Do you love Textual?", id="question")
yield Button("Yes", id="yes", variant="primary")
yield Button("No", id="no", variant="error")
def on_button_pressed(self, event: Button.Pressed) -> None:
self.exit(event.button.id)
app = QuestionApp()
if __name__ == "__main__":
reply = app.run()
print(reply)