mirror of
https://github.com/onyx-and-iris/lottery-tui.git
synced 2026-02-26 02:59:10 +00:00
remove default empty option
select now defaults to Lotto patch bump
This commit is contained in:
parent
a2ab27fa5b
commit
cfba2303e6
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "lottery-tui"
|
name = "lottery-tui"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
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"]
|
||||||
|
|||||||
@ -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,8 @@ class LotteryTUI(App):
|
|||||||
('Set For Life', 'setforlife'),
|
('Set For Life', 'setforlife'),
|
||||||
('Thunderball', 'thunderball'),
|
('Thunderball', 'thunderball'),
|
||||||
],
|
],
|
||||||
|
value='lotto',
|
||||||
|
allow_blank=False,
|
||||||
id='lottery-select',
|
id='lottery-select',
|
||||||
),
|
),
|
||||||
Button('Draw', id='draw-button'),
|
Button('Draw', id='draw-button'),
|
||||||
@ -46,22 +47,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."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user