7 Commits

Author SHA1 Message Date
1efd518e9f add pre-commit config 2026-03-21 14:21:34 +00:00
a8a46f718d upd README. 2026-03-20 09:56:45 +00:00
5eaa521b8d fix Set For Life pool size.
patch bump
2026-02-26 16:45:12 +00:00
19b4f32c5a patch bump 2026-02-26 14:02:18 +00:00
1bd6c0e94f enable type_to_earch in Select widget 2026-02-26 14:02:01 +00:00
cfba2303e6 remove default empty option
select now defaults to Lotto

patch bump
2026-02-26 01:02:35 +00:00
a2ab27fa5b bump to version 1.0.0. TUI is considered complete. 2026-02-25 21:39:47 +00:00
5 changed files with 22 additions and 17 deletions

12
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pdm-project/pdm
rev: 2.26.6
hooks:
- id: pdm-lock-check

View File

@@ -34,7 +34,7 @@ The TUI should now be discoverable as lottery-tui.
Launch the TUI, select a lottery and press the Draw button! Launch the TUI, select a lottery and press the Draw button!
To exit from the application press *q* or *Ctrl+q* To exit from the application press `Ctrl+q`.
## License ## License

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "lottery-tui" name = "lottery-tui"
version = "0.2.8" version = "1.0.3"
description = "A terminal user interface for lottery games." description = "A terminal user interface for lottery games."
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }] authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
dependencies = ["textual>=8.0.0", "loguru>=0.7.3"] dependencies = ["textual>=8.0.0", "loguru>=0.7.3"]
@@ -8,7 +8,7 @@ requires-python = ">=3.10"
readme = "README.md" readme = "README.md"
license = { text = "MIT" } license = { text = "MIT" }
classifiers = [ classifiers = [
"Development Status :: 4 - Beta", "Development Status :: 5 - Production/Stable",
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",

View File

@@ -94,11 +94,11 @@ class EuroMillions(Lottery):
class SetForLife(Lottery): class SetForLife(Lottery):
"""A class representing the Set For Life lottery. """A class representing the Set For Life lottery.
Set For Life draws 5 numbers from a pool of 1 to 39, without replacement, Set For Life draws 5 numbers from a pool of 1 to 47, without replacement,
and 1 "Life Ball" number from a separate pool of 1 to 10. and 1 "Life Ball" number from a separate pool of 1 to 10.
""" """
POSSIBLE_NUMBERS = range(1, 40) POSSIBLE_NUMBERS = range(1, 48)
def draw(self) -> Result: def draw(self) -> Result:
"""Perform a Set For Life draw.""" """Perform a Set For Life draw."""

View File

@@ -1,6 +1,5 @@
from typing import NoReturn from typing import NoReturn
from rich.text import Text
from textual.app import App, ComposeResult from textual.app import App, ComposeResult
from textual.containers import Container from textual.containers import Container
from textual.events import Key from textual.events import Key
@@ -27,6 +26,9 @@ class LotteryTUI(App):
('Set For Life', 'setforlife'), ('Set For Life', 'setforlife'),
('Thunderball', 'thunderball'), ('Thunderball', 'thunderball'),
], ],
value='lotto',
allow_blank=False,
type_to_search=True,
id='lottery-select', id='lottery-select',
), ),
Button('Draw', id='draw-button'), Button('Draw', id='draw-button'),
@@ -46,22 +48,13 @@ class LotteryTUI(App):
def _draw_button_handler(self) -> None: def _draw_button_handler(self) -> None:
"""Handle the draw button press.""" """Handle the draw button press."""
if self._read_lottery_selection() is None:
self._update_result_label(
Text('Please select a lottery before drawing.', style='bold #ff8c42')
)
return
lottery_obj = request_lottery_obj(self._read_lottery_selection()) lottery_obj = request_lottery_obj(self._read_lottery_selection())
result = lottery_obj.draw() result = lottery_obj.draw()
self._update_result_label(str(result)) self._update_result_label(str(result))
def _read_lottery_selection(self) -> SelectType | None: def _read_lottery_selection(self) -> SelectType:
"""Read the selected lottery from the dropdown.""" """Read the selected lottery from the dropdown."""
select_widget = self.query_one('#lottery-select') return self.query_one('#lottery-select').value
if select_widget.is_blank():
return None
return select_widget.value
def _update_result_label(self, message: str) -> None: def _update_result_label(self, message: str) -> None:
"""Update the result label with a new message.""" """Update the result label with a new message."""