MIL-002: Step 1 - User interface

Review record RC-024 (Go, autonomous mode, not independent).

Task: MIL-002#1
Task: MIL-002#2
Task: MIL-002#3
Task: MIL-002#4
This commit is contained in:
2026-10-14 21:53:07 +08:00
parent aecf7ad43c
commit 019565635d
18 changed files with 828 additions and 33 deletions
+44 -28
View File
@@ -1,28 +1,44 @@
"""Entry point of the flash card program.
@file app.py
@brief Starts the program; the window arrives in MIL-002.
"""
from collections.abc import Sequence
from typing import NoReturn
def main(argv: Sequence[str] | None = None) -> int:
"""Run the program and return its exit code.
The window arrives in MIL-002; for now nothing happens.
@param argv Command line arguments, or None for none.
@return The exit code, 0 on success.
"""
return 0
def run() -> NoReturn:
"""Run the program and exit the interpreter with its exit code.
@return Never returns; the function always raises SystemExit.
@throws SystemExit Always, with the exit code of main.
"""
raise SystemExit(main())
"""Entry point and composition root of the flash card program.
@file app.py
@brief Creates the window, its view model and view, and runs the main loop.
"""
import tkinter as tk
from collections.abc import Sequence
from typing import NoReturn
from flash_card.presentation.features.flash_card.flash_card_view import FlashCardView
from flash_card.presentation.features.flash_card.flash_card_view_model import (
FlashCardViewModel,
)
def create_application() -> tuple[tk.Tk, FlashCardView]:
"""Create the root window and the flash card view.
@return The root window and the view built on it.
"""
root = tk.Tk()
view = FlashCardView(root, FlashCardViewModel())
return root, view
def main(argv: Sequence[str] | None = None) -> int:
"""Run the program and return its exit code.
@param argv Command line arguments, or None for none.
@return The exit code, 0 on success.
"""
root, _view = create_application()
root.mainloop()
return 0
def run() -> NoReturn:
"""Run the program and exit the interpreter with its exit code.
@return Never returns; the function always raises SystemExit.
@throws SystemExit Always, with the exit code of main.
"""
raise SystemExit(main())