05/23 Phase 22

This commit is contained in:
2026-05-23 17:36:33 -04:00
parent edd2ed5660
commit 59789f3cfe
10 changed files with 358 additions and 23 deletions
+37 -5
View File
@@ -54,6 +54,7 @@ class DashboardScreen(ttk.Frame):
def __init__(self, parent, on_fetch=None, **kwargs):
super().__init__(parent, **kwargs)
self._on_fetch = on_fetch
self._filter_var = tk.StringVar(value="All Games")
self._build_ui()
# ── Layout ────────────────────────────────────────────────────────────────
@@ -66,7 +67,7 @@ class DashboardScreen(ttk.Frame):
vsb.pack(side="right", fill="y")
canvas.pack(side="left", fill="both", expand=True)
inner = ttk.Frame(canvas, padding=(28, 20, 28, 20))
inner = ttk.Frame(canvas, padding=(28, 16, 28, 20))
win = canvas.create_window((0, 0), window=inner, anchor="nw")
def _resize(event=None):
@@ -82,6 +83,18 @@ class DashboardScreen(ttk.Frame):
lambda e: canvas.unbind_all("<MouseWheel>"))
self._inner = inner
# Game filter bar
filter_bar = ttk.Frame(inner)
filter_bar.pack(fill="x", pady=(0, 12))
ttk.Label(filter_bar, text="Show game:").pack(side="left", padx=(0, 6))
self._game_filter = ttk.Combobox(
filter_bar, textvariable=self._filter_var,
state="readonly", width=22,
)
self._game_filter.pack(side="left")
self._game_filter.bind("<<ComboboxSelected>>", lambda _e: self.refresh())
self._draw_sections()
def _section_header(self, title: str):
@@ -101,7 +114,22 @@ class DashboardScreen(ttk.Frame):
# ── Refresh ───────────────────────────────────────────────────────────────
def _update_filter_options(self):
games = get_all_games(active_only=True)
names = ["All Games"] + [g["name"] for g in games]
self._game_filter["values"] = names
if self._filter_var.get() not in names:
self._filter_var.set("All Games")
def _filtered_games(self):
games = get_all_games(active_only=True)
sel = self._filter_var.get()
if not sel or sel == "All Games":
return games
return [g for g in games if g["name"] == sel]
def refresh(self):
self._update_filter_options()
self._refresh_last_draws()
self._refresh_db_summary()
self._refresh_hot_numbers()
@@ -111,13 +139,12 @@ class DashboardScreen(ttk.Frame):
for w in self._last_draw_body.winfo_children():
w.destroy()
games = get_all_games(active_only=True)
games = self._filtered_games()
if not games:
ttk.Label(self._last_draw_body, text="No active games.",
foreground="#aaaaaa").pack(anchor="w")
return
# Lay cards out in a horizontal row that wraps via grid
row_frame = ttk.Frame(self._last_draw_body)
row_frame.pack(fill="x")
@@ -128,6 +155,11 @@ class DashboardScreen(ttk.Frame):
)
card.grid(row=0, column=col_idx, padx=(0, 16), sticky="nw")
top_prize = game["top_prize"] if "top_prize" in game.keys() else ""
if top_prize:
ttk.Label(card, text=f"Top prize: {top_prize}",
foreground="#8e44ad", font=_CARD_FONT).pack(anchor="w")
if draw is None:
ttk.Label(card, text="No draws yet.", foreground="#aaaaaa",
font=_CARD_FONT).pack(anchor="w")
@@ -172,7 +204,7 @@ class DashboardScreen(ttk.Frame):
for w in self._hot_body.winfo_children():
w.destroy()
games = get_all_games(active_only=True)
games = self._filtered_games()
if not games:
ttk.Label(self._hot_body, text="No active games.",
foreground="#aaaaaa").pack(anchor="w")
@@ -201,7 +233,7 @@ class DashboardScreen(ttk.Frame):
for w in self._overdue_body.winfo_children():
w.destroy()
games = get_all_games(active_only=True)
games = self._filtered_games()
if not games:
ttk.Label(self._overdue_body, text="No active games.",
foreground="#aaaaaa").pack(anchor="w")