Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ The format follows [Keep a Changelog](https://keepachangelog.com/); versions fol

### Fixed

- **The two LAN checkboxes were touching.** "Internet only" started right where the "LAN mode"
label ended, with nothing between them, so the pair read as one control. They now have the same
gap as any other two settings sharing a row.
- The right-click copy menu on the Statistics page opened with a white background instead of the
dark one used everywhere else. It now looks like the menu in the Connections table, on both
Live and Session.
Expand Down
19 changes: 16 additions & 3 deletions beantester/gui/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ def _takes_a_row(field):
neighbour. Only the registry may say so - the caller reads the answer.
"""
return field.kind in SPAN_KINDS if field.span is None else field.span


def _gap_after(field):
"""How much room to leave to the RIGHT of a field inside its row.

A field that owns its row only has to clear the card's edge. Two that SHARE
one need a real gap between them, or they read as a single control: the pair
of LAN switches shipped touching, the second one's box hard against the end
of the first one's label, because the checkbox branch packed with no padding
at all while every other kind went through a cell that had some.

One place, so the two paths cannot drift apart again.
"""
return scaled(6) if _takes_a_row(field) else scaled(22)
VALIDATED_KINDS = (F.NUMBER, F.EXPR, F.SCHEDULE, F.SEED)

# Below this width a second column of sections would squeeze the wider rows
Expand Down Expand Up @@ -216,7 +230,7 @@ def _place_one(self, row, field, sec):
widget = ttk.Checkbutton(row, text=T(field.label),
variable=app.vars[field.key],
command=app.on_form_changed)
widget.pack(side="left", anchor="w")
widget.pack(side="left", anchor="w", padx=(0, _gap_after(field)))
add_tooltip(widget, field.tip)
self.entries[field.key] = widget
return
Expand All @@ -240,8 +254,7 @@ def _place_one(self, row, field, sec):

span = _takes_a_row(field)
cell = ttk.Frame(row, style="Card.TFrame")
cell.pack(side="left", fill="x", expand=span,
padx=(0, scaled(6) if span else scaled(22)))
cell.pack(side="left", fill="x", expand=span, padx=(0, _gap_after(field)))

label = ttk.Label(cell, text=T(field.label), style="Card.TLabel")
label.pack(side="left", padx=(0, scaled(6)))
Expand Down
8 changes: 8 additions & 0 deletions tests/test_gui_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,4 +932,12 @@ def test_the_two_lan_switches_share_one_row():
assert lan.master is net.master, "the LAN switches are not in one row"
assert app.form.entries["filter"].master is not lan.master, (
"the traffic dropdown was pulled into the checkbox row")

# ...and they must not TOUCH. They shipped with the second one's box hard
# against the end of the first one's label, because the checkbox branch
# packed with no padding while every other kind went through a cell that
# had some. Two controls with nothing between them read as one.
gap = (lan.pack_info or {}).get("padx")
gap = gap[1] if isinstance(gap, (tuple, list)) else gap
assert gap, "no room to the right of the first switch: %r" % (lan.pack_info,)
""")
10 changes: 10 additions & 0 deletions tests/test_mutation_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,16 @@
"new": " return field.kind in SPAN_KINDS",
"test": "test_the_two_lan_switches_share_one_row",
},
{
# How they shipped touching: the checkbox branch packed with no padding
# while every other kind went through a cell that had some, so the pair
# only looked wrong once two of them ended up in one row.
"label": "gui: paired checkboxes lose the gap between them",
"file": "beantester/gui/form.py",
"old": ' widget.pack(side="left", anchor="w", padx=(0, _gap_after(field)))',
"new": ' widget.pack(side="left", anchor="w")',
"test": "test_the_two_lan_switches_share_one_row",
},
{
# Without the idle hint the row is one cluster in a band of nothing -
# the shape that has now been reported twice.
Expand Down
Loading