11from typing import NoReturn
22
3- from rich .text import Text
43from textual .app import App , ComposeResult
54from textual .containers import Container
65from textual .events import Key
@@ -27,6 +26,8 @@ def compose(self) -> ComposeResult:
2726 ('Set For Life' , 'setforlife' ),
2827 ('Thunderball' , 'thunderball' ),
2928 ],
29+ value = 'lotto' ,
30+ allow_blank = False ,
3031 id = 'lottery-select' ,
3132 ),
3233 Button ('Draw' , id = 'draw-button' ),
@@ -46,22 +47,13 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
4647
4748 def _draw_button_handler (self ) -> None :
4849 """Handle the draw button press."""
49- if self ._read_lottery_selection () is None :
50- self ._update_result_label (
51- Text ('Please select a lottery before drawing.' , style = 'bold #ff8c42' )
52- )
53- return
54-
5550 lottery_obj = request_lottery_obj (self ._read_lottery_selection ())
5651 result = lottery_obj .draw ()
5752 self ._update_result_label (str (result ))
5853
59- def _read_lottery_selection (self ) -> SelectType | None :
54+ def _read_lottery_selection (self ) -> SelectType :
6055 """Read the selected lottery from the dropdown."""
61- select_widget = self .query_one ('#lottery-select' )
62- if select_widget .is_blank ():
63- return None
64- return select_widget .value
56+ return self .query_one ('#lottery-select' ).value
6557
6658 def _update_result_label (self , message : str ) -> None :
6759 """Update the result label with a new message."""
0 commit comments