remove footer, add input method

1-reproducible-board
Felix Pankratz 5 months ago
parent 3cded45cfd
commit 725b30256d

@ -58,13 +58,10 @@ class BingoApp(App):
"""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."""
@ -88,7 +85,7 @@ class BingoDisplay(Static):
self.input_field.border_title = 'Seed'
yield Horizontal(
self.input_field,
Button('re-roll', classes='roll_btn'),
Button.error(':game_die: re-roll', classes='roll_btn'),
classes='bottom_line'
)
@ -98,6 +95,10 @@ class BingoDisplay(Static):
self.board.roll_board(int(datetime.now().timestamp()))
self.input_field.value = str(self.board.seed)
def on_input_submitted(self, event: Input.Submitted) -> None:
if event.validation_result:
self.board.roll_board(int(event.value))
class BingoBoard(Widget):
fields = reactive([], recompose = True)
@ -132,19 +133,15 @@ class BingoBoard(Widget):
'geduscht',
'Gulasch gegessen'
]
self.default_fields = self.fields
self.roll_board(int(datetime.now().timestamp()))
def roll_board(self, seed):
print('rolling board.')
self.seed = seed
random.seed(seed)
self.fields = random.sample(self.fields, len(self.fields))
print('board after shuf:')
print(self.fields)
self.fields = random.sample(self.default_fields, len(self.fields))
def watch_fields(self, new_state) -> None:
print('watch_fields: called')
self.fieldstate = [False for _ in range(25)]
for idx, field in enumerate(self.query(BingoField)):
field.text = new_state[idx]

Loading…
Cancel
Save