From ae741a44b7b13616b326d8d6840d3b695624b08c Mon Sep 17 00:00:00 2001 From: Peyton Date: Mon, 23 Mar 2026 22:07:53 +0800 Subject: [PATCH] feat: add row / column coordinates --- minesweeper/ui/board_view.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/minesweeper/ui/board_view.py b/minesweeper/ui/board_view.py index 0545ea8..69245ee 100644 --- a/minesweeper/ui/board_view.py +++ b/minesweeper/ui/board_view.py @@ -4,6 +4,7 @@ from textual.containers import Grid from textual.message import Message from textual.widget import Widget +from textual.widgets import Label from minesweeper.game.state import GameState from minesweeper.ui.widgets import CellButton @@ -25,9 +26,9 @@ def __init__(self, status_text: str) -> None: } BoardView Grid { - grid-size: 10 10; - grid-columns: 5 5 5 5 5 5 5 5 5 5; - grid-rows: 3 3 3 3 3 3 3 3 3 3; + grid-size: 11 11; + grid-columns: 5 5 5 5 5 5 5 5 5; + grid-rows: 3 3 3 3 3 3 3 3 3; grid-gutter: 0 0; } @@ -94,6 +95,15 @@ def __init__(self, status_text: str) -> None: BoardView CellButton.-count-8 { color: #4c566a; } + + BoardView .coord-label { + width: 5; + height: 3; + content-align: center middle; + background: transparent; + color: $foreground; + text-style: bold; + } """ def __init__(self, state: GameState) -> None: @@ -102,7 +112,11 @@ def __init__(self, state: GameState) -> None: def compose(self) -> ComposeResult: with Grid(): + yield Label(str(""), classes="coord-label") + for x in range(self.state.width): + yield Label(str(x), classes="coord-label") for y, row in enumerate(self.state.board): + yield Label(str(y), classes="coord-label") for x, cell in enumerate(row): yield CellButton(x, y, cell)