mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge pull request #1007 from davep/5x5-tidy
Tidy up some of the documentation in the FiveByFive example
This commit is contained in:
@@ -24,8 +24,8 @@ from rich.markdown import Markdown
|
|||||||
class Help(Screen):
|
class Help(Screen):
|
||||||
"""The help screen for the application."""
|
"""The help screen for the application."""
|
||||||
|
|
||||||
#: Bindings for the help screen.
|
|
||||||
BINDINGS = [("escape,space,q,question_mark", "pop_screen", "Close")]
|
BINDINGS = [("escape,space,q,question_mark", "pop_screen", "Close")]
|
||||||
|
"""Bindings for the help screen."""
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
"""Compose the game's help.
|
"""Compose the game's help.
|
||||||
@@ -39,8 +39,8 @@ class Help(Screen):
|
|||||||
class WinnerMessage(Static):
|
class WinnerMessage(Static):
|
||||||
"""Widget to tell the user they have won."""
|
"""Widget to tell the user they have won."""
|
||||||
|
|
||||||
#: The minimum number of moves you can solve the puzzle in.
|
|
||||||
MIN_MOVES: Final = 14
|
MIN_MOVES: Final = 14
|
||||||
|
"""int: The minimum number of moves you can solve the puzzle in."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _plural(value: int) -> str:
|
def _plural(value: int) -> str:
|
||||||
@@ -78,11 +78,11 @@ class GameHeader(Widget):
|
|||||||
and the count of how many cells are turned on (``#progress``).
|
and the count of how many cells are turned on (``#progress``).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#: Keep track of how many moves the player has made.
|
|
||||||
moves = reactive(0)
|
moves = reactive(0)
|
||||||
|
"""int: Keep track of how many moves the player has made."""
|
||||||
|
|
||||||
#: Keep track of how many cells are filled.
|
|
||||||
filled = reactive(0)
|
filled = reactive(0)
|
||||||
|
"""int: Keep track of how many cells are filled."""
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
"""Compose the game header.
|
"""Compose the game header.
|
||||||
@@ -159,10 +159,9 @@ class GameGrid(Widget):
|
|||||||
class Game(Screen):
|
class Game(Screen):
|
||||||
"""Main 5x5 game grid screen."""
|
"""Main 5x5 game grid screen."""
|
||||||
|
|
||||||
#: The size of the game grid. Clue's in the name really.
|
SIZE: Final = 5
|
||||||
SIZE = 5
|
"""The size of the game grid. Clue's in the name really."""
|
||||||
|
|
||||||
#: The bindings for the main game grid.
|
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
Binding("n", "new_game", "New Game"),
|
Binding("n", "new_game", "New Game"),
|
||||||
Binding("question_mark", "push_screen('help')", "Help", key_display="?"),
|
Binding("question_mark", "push_screen('help')", "Help", key_display="?"),
|
||||||
@@ -173,6 +172,7 @@ class Game(Screen):
|
|||||||
Binding("right,d,l", "navigate(0,1)", "Move Right", False),
|
Binding("right,d,l", "navigate(0,1)", "Move Right", False),
|
||||||
Binding("space", "move", "Toggle", False),
|
Binding("space", "move", "Toggle", False),
|
||||||
]
|
]
|
||||||
|
"""The bindings for the main game grid."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def filled_cells(self) -> DOMQuery[GameCell]:
|
def filled_cells(self) -> DOMQuery[GameCell]:
|
||||||
@@ -308,17 +308,17 @@ class Game(Screen):
|
|||||||
class FiveByFive(App[None]):
|
class FiveByFive(App[None]):
|
||||||
"""Main 5x5 application class."""
|
"""Main 5x5 application class."""
|
||||||
|
|
||||||
#: The name of the stylesheet for the app.
|
|
||||||
CSS_PATH = "five_by_five.css"
|
CSS_PATH = "five_by_five.css"
|
||||||
|
"""The name of the stylesheet for the app."""
|
||||||
|
|
||||||
#: The pre-loaded screens for the application.
|
|
||||||
SCREENS = {"help": Help()}
|
SCREENS = {"help": Help()}
|
||||||
|
"""The pre-loaded screens for the application."""
|
||||||
|
|
||||||
#: App-level bindings.
|
|
||||||
BINDINGS = [("ctrl+d", "toggle_dark", "Toggle Dark Mode")]
|
BINDINGS = [("ctrl+d", "toggle_dark", "Toggle Dark Mode")]
|
||||||
|
"""App-level bindings."""
|
||||||
|
|
||||||
# Set the title
|
|
||||||
TITLE = "5x5 -- A little annoying puzzle"
|
TITLE = "5x5 -- A little annoying puzzle"
|
||||||
|
"""The title of the application."""
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
"""Set up the application on startup."""
|
"""Set up the application on startup."""
|
||||||
|
|||||||
Reference in New Issue
Block a user