mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-11 22:13:53 +01:00
The gate is laid out once per live output instead of once on the primary, and claims the screen through an Arbiter at RANK_DIET_GUARD so the wake alarm and the workout locker can both outrank it. Three kinds of state needed three different answers. The display fields already fanned out for free -- GateVars holds root-mastered StringVars bound to labels. The typed-in fields did not: amount, per, meal name and the four macro cells were bare tk.Entry widgets, so N copies would have been N independent forms. They are variable-backed now, which is what makes logging work from whichever screen the user is actually looking at. The description box and the suggestion list cannot be shared at all -- tk.Text and tk.Listbox have no variable -- so those genuinely diverge and reads answer from the copy the user touched. The History tab is per-surface too: its grid, budget field and edit button are driven across every monitor, with the budget likewise variable-backed so the value cannot differ between screens mid-edit. Laying the gate out on the primary monitor only was considered and rejected: not having to hunt for the screen the form landed on is the entire point of per-output locking. Tests: the suite hung rather than failed on first run -- diet_guard patches its own `tk`, but LockWindow builds Toplevels through gatelock's, and real tkinter over a MagicMock root recurses without bound. `_hermetic_gatelock` closes that and redirects the runtime dir so no test can stand a production locker down. Every other test runs single-output, where fan-out is unobservable, so test_gatelock_fanout runs on two; each assertion was checked by cropping the fan-out loops to the first surface and confirming it goes red. _gatelock_ui and _gatelock_calendar were each split in two to stay under the 500-line limit, and GateVars' typed-in fields moved into a nested GateEntryVars rather than raising pylint's attribute cap. 470 tests, 100% branch coverage, pre-commit clean, no lint suppressions.
19 lines
596 B
Python
19 lines
596 B
Python
"""Shared type scale for the diet_guard gate (tokens.md's typography scale).
|
|
|
|
Split out so :mod:`._gatelock_ui`, :mod:`._gatelock_calendar`, and
|
|
:mod:`._gatelock_buttons` read the same sizes instead of each picking its
|
|
own point value per label -- see ``DESIGN_AUDIT_TODO.md``. Values are the
|
|
px sizes from ``~/utils/unified-design-system/tokens.md``'s typography
|
|
scale, used directly as Tk point sizes (Tk has no separate px/pt distinction
|
|
in this codebase's existing font tuples).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
DISPLAY = 32
|
|
TITLE = 24
|
|
SUBTITLE = 20
|
|
BODY = 16
|
|
LABEL = 14
|
|
CAPTION = 12
|