05/23 Phase 16
This commit is contained in:
@@ -13,6 +13,7 @@ from db.models import get_all_games, get_game_by_name, get_draws_with_game
|
||||
from core.exporter import (
|
||||
export_draws_excel, export_draws_csv, default_path, ensure_exports_dir,
|
||||
)
|
||||
from ui.widgets import BallsBar
|
||||
|
||||
_COLUMNS = ("game", "date", "numbers", "bonus", "multiplier", "source")
|
||||
_LABELS = {
|
||||
@@ -115,6 +116,15 @@ class HistoryScreen(ttk.Frame):
|
||||
tree_frame.rowconfigure(0, weight=1)
|
||||
tree_frame.columnconfigure(0, weight=1)
|
||||
|
||||
# ── Ball detail strip ─────────────────────────────────────────────────
|
||||
ttk.Separator(self, orient="horizontal").pack(fill="x", padx=6)
|
||||
self._detail_frame = ttk.Frame(self, padding=(8, 3, 8, 3))
|
||||
self._detail_frame.pack(fill="x")
|
||||
ttk.Label(self._detail_frame, text="Select a row to preview.",
|
||||
foreground="#aaaaaa", font=("TkDefaultFont", 8)).pack(anchor="w")
|
||||
|
||||
self._tree.bind("<<TreeviewSelect>>", self._on_row_select)
|
||||
|
||||
# ── Row count ─────────────────────────────────────────────────────────
|
||||
self._count_var = tk.StringVar(value="0 rows")
|
||||
ttk.Label(self, textvariable=self._count_var, anchor="e",
|
||||
@@ -173,6 +183,7 @@ class HistoryScreen(ttk.Frame):
|
||||
|
||||
def _populate(self, rows):
|
||||
self._tree.delete(*self._tree.get_children())
|
||||
self._clear_detail()
|
||||
for row in rows:
|
||||
self._tree.insert("", "end", values=(
|
||||
row["game_name"],
|
||||
@@ -185,6 +196,38 @@ class HistoryScreen(ttk.Frame):
|
||||
count = len(rows)
|
||||
self._count_var.set(f"{count} row{'s' if count != 1 else ''}")
|
||||
|
||||
def _clear_detail(self):
|
||||
for w in self._detail_frame.winfo_children():
|
||||
w.destroy()
|
||||
ttk.Label(self._detail_frame, text="Select a row to preview.",
|
||||
foreground="#aaaaaa", font=("TkDefaultFont", 8)).pack(anchor="w")
|
||||
|
||||
def _on_row_select(self, _event=None):
|
||||
sel = self._tree.selection()
|
||||
if not sel:
|
||||
self._clear_detail()
|
||||
return
|
||||
vals = self._tree.item(sel[0], "values")
|
||||
# vals: (game, date, numbers_fmt, bonus, multiplier, source)
|
||||
nums_text = vals[2] # e.g. "1 13 36 61 69"
|
||||
bonus_text = str(vals[3])
|
||||
try:
|
||||
nums = [int(x) for x in nums_text.split() if x.isdigit()]
|
||||
bonus = int(bonus_text) if bonus_text.isdigit() else None
|
||||
except Exception:
|
||||
self._clear_detail()
|
||||
return
|
||||
if not nums:
|
||||
self._clear_detail()
|
||||
return
|
||||
for w in self._detail_frame.winfo_children():
|
||||
w.destroy()
|
||||
row_frame = ttk.Frame(self._detail_frame)
|
||||
row_frame.pack(anchor="w")
|
||||
ttk.Label(row_frame, text=vals[1], foreground="#555555",
|
||||
font=("TkDefaultFont", 8), width=11).pack(side="left")
|
||||
BallsBar(row_frame, numbers=nums, bonus=bonus).pack(side="left")
|
||||
|
||||
# ── Sorting ───────────────────────────────────────────────────────────────
|
||||
|
||||
def _sort_by(self, col):
|
||||
|
||||
Reference in New Issue
Block a user