-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwelcome.py
More file actions
45 lines (36 loc) · 1.52 KB
/
Copy pathwelcome.py
File metadata and controls
45 lines (36 loc) · 1.52 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
# pythonlings/screens/welcome.py
from __future__ import annotations
from textual.app import ComposeResult
from textual.binding import Binding
from textual.containers import Vertical
from textual.screen import ModalScreen
from textual.widgets import Static
from pythonlings.core.state import save as save_state
def welcome_text() -> str:
"""The first-launch explainer for the edit/save/advance loop."""
return (
"You learn Python here by fixing small broken programs. The loop is:\n\n"
" 1. Edit the current exercise in the built-in editor.\n"
" 2. Save -- the check reruns automatically as you type.\n"
" 3. Remove the `# I AM NOT DONE` marker to advance to the next one.\n\n"
"Handy keys: F1 hint - F3 exercise list - F4 topics - "
"F5 local docs - Ctrl+Q quit.\n\n"
"Press Enter to start."
)
class WelcomeScreen(ModalScreen[None]):
"""First-launch onboarding overlay explaining the core loop."""
BINDINGS = [
Binding("enter", "start", "Start", priority=True),
Binding("escape", "start", "Start"),
]
def compose(self) -> ComposeResult:
yield Vertical(
Static("[bold]Welcome to pythonlings[/bold]", id="welcome-title"),
Static(welcome_text(), id="welcome-body"),
Static("Enter Start", id="welcome-footer"),
id="welcome-window",
)
def action_start(self) -> None:
self.app.state.seen_intro = True
save_state(self.app.root, self.app.state)
self.dismiss()