mirror of
https://github.com/onyx-and-iris/lottery-tui.git
synced 2026-02-26 11:09:11 +00:00
Compare commits
No commits in common. "main" and "v0.2.8" have entirely different histories.
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "lottery-tui"
|
||||
version = "1.0.1"
|
||||
version = "0.2.8"
|
||||
description = "A terminal user interface for lottery games."
|
||||
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
||||
dependencies = ["textual>=8.0.0", "loguru>=0.7.3"]
|
||||
@ -8,7 +8,7 @@ requires-python = ">=3.10"
|
||||
readme = "README.md"
|
||||
license = { text = "MIT" }
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from typing import NoReturn
|
||||
|
||||
from rich.text import Text
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container
|
||||
from textual.events import Key
|
||||
@ -26,8 +27,6 @@ class LotteryTUI(App):
|
||||
('Set For Life', 'setforlife'),
|
||||
('Thunderball', 'thunderball'),
|
||||
],
|
||||
value='lotto',
|
||||
allow_blank=False,
|
||||
id='lottery-select',
|
||||
),
|
||||
Button('Draw', id='draw-button'),
|
||||
@ -47,13 +46,22 @@ class LotteryTUI(App):
|
||||
|
||||
def _draw_button_handler(self) -> None:
|
||||
"""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())
|
||||
result = lottery_obj.draw()
|
||||
self._update_result_label(str(result))
|
||||
|
||||
def _read_lottery_selection(self) -> SelectType:
|
||||
def _read_lottery_selection(self) -> SelectType | None:
|
||||
"""Read the selected lottery from the dropdown."""
|
||||
return self.query_one('#lottery-select').value
|
||||
select_widget = self.query_one('#lottery-select')
|
||||
if select_widget.is_blank():
|
||||
return None
|
||||
return select_widget.value
|
||||
|
||||
def _update_result_label(self, message: str) -> None:
|
||||
"""Update the result label with a new message."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user