|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
from textual.app import App, ComposeResult
|
|
|
|
|
from textual.widgets import Header, Footer, Button, Label, Switch, Static
|
|
|
|
|
from textual.containers import ScrollableContainer
|
|
|
|
|
from textual.widgets import Header, Footer, Input, Label, Static, Button
|
|
|
|
|
from textual.message import Message
|
|
|
|
|
from textual.color import Color
|
|
|
|
|
from textual.containers import Horizontal
|
|
|
|
|
|
|
|
|
|
from asyncio import sleep
|
|
|
|
|
|
|
|
|
@ -51,11 +51,40 @@ class BingoField(Static):
|
|
|
|
|
return str(self.text)
|
|
|
|
|
|
|
|
|
|
class BingoApp(App):
|
|
|
|
|
"""A Textual app to manage stopwatches."""
|
|
|
|
|
"""A Textual app to run a Bingo board."""
|
|
|
|
|
CSS_PATH = "bingo.tcss"
|
|
|
|
|
|
|
|
|
|
BINDINGS = [("d", "toggle_dark", "Toggle dark mode")]
|
|
|
|
|
|
|
|
|
|
def compose(self) -> ComposeResult:
|
|
|
|
|
"""Create child widgets for the app."""
|
|
|
|
|
yield Header()
|
|
|
|
|
yield BingoDisplay()
|
|
|
|
|
yield Footer()
|
|
|
|
|
|
|
|
|
|
def action_toggle_dark(self) -> None:
|
|
|
|
|
"""An action to toggle dark mode."""
|
|
|
|
|
self.dark = not self.dark
|
|
|
|
|
|
|
|
|
|
class BingoDisplay(Static):
|
|
|
|
|
def compose(self) -> ComposeResult:
|
|
|
|
|
"""Create child widgets for the app."""
|
|
|
|
|
yield BingoBoard()
|
|
|
|
|
input_field = Input(
|
|
|
|
|
type='integer',
|
|
|
|
|
placeholder='UNIX timestamp',
|
|
|
|
|
max_length=10,
|
|
|
|
|
classes='seed_input'
|
|
|
|
|
)
|
|
|
|
|
input_field.border_title = 'Seed'
|
|
|
|
|
yield Horizontal(
|
|
|
|
|
input_field,
|
|
|
|
|
Button('re-roll', classes='roll_btn'),
|
|
|
|
|
classes='bottom_line'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
class BingoBoard(Static):
|
|
|
|
|
|
|
|
|
|
fieldstate = [False for _ in range(25)]
|
|
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
@ -93,13 +122,9 @@ class BingoApp(App):
|
|
|
|
|
|
|
|
|
|
def compose(self) -> ComposeResult:
|
|
|
|
|
"""Create child widgets for the app."""
|
|
|
|
|
yield Header()
|
|
|
|
|
|
|
|
|
|
for _ in range(25):
|
|
|
|
|
yield BingoField(_, self.fields[_])
|
|
|
|
|
|
|
|
|
|
yield Footer()
|
|
|
|
|
|
|
|
|
|
async def on_bingo_field_selected(self, message: BingoField.Selected) -> None:
|
|
|
|
|
self.fieldstate[message.num] = message.selected
|
|
|
|
|
if self.is_bingo():
|
|
|
|
@ -143,10 +168,6 @@ class BingoApp(App):
|
|
|
|
|
])
|
|
|
|
|
return bingo
|
|
|
|
|
|
|
|
|
|
def action_toggle_dark(self) -> None:
|
|
|
|
|
"""An action to toggle dark mode."""
|
|
|
|
|
self.dark = not self.dark
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
app = BingoApp()
|
|
|
|
|
app.run()
|
|
|
|
|