Skip to content

[GUI] Lay out dialogs as EEGLAB's supergui does, with a geometry test suite of ten dialogs - #878

Merged
arnodelorme merged 6 commits into
developfrom
agent/issue-875
Nov 29, 2026
Merged

arnodelorme merged 6 commits into
developfrom
agent/issue-875

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

The same geometry now gives the same window in EEGLAB and in EEGPrep. EEGPrep's supergui is rewritten as a port of the arithmetic of supergui.m and inputgui.m (borders, spacing, row and column shares, the empty row and the row of Help, Cancel and Ok), ten dialogs are moved to it, and a geometry test suite of these ten dialogs stays in the repository. The text of an edit box is centered in every dialog, as in MATLAB.

On Linux (jamming, MATLAB R2025b) the ten EEGPrep windows have MATLAB's height, their rows sit within 0.7 pixel of MATLAB's, and their edit boxes line up as in MATLAB. A vision model (Codex, gpt-6.1-terra) finds the ten pairs close enough on the five rules of the issue; it rejects the ten pairs taken from develop.

pop_resample: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_rmbase: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_reref: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_autorej: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_eegthresh: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_rejspec: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_plottopo: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_firws: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_dipfit_gridsearch: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

pop_iclabel: EEGLAB, EEGPrep on develop, EEGPrep with this pull request

Dialog EEGLAB EEGPrep before EEGPrep after Rows after (pixels from MATLAB) Width after Vision before Vision after
pop_resample 277 x 147 356 x 219 276 x 147 0.4 -0.4% 2 of 5 fail 5 of 5 pass
pop_rmbase 736 x 221 716 x 360 746 x 221 0.5 +1.4% 3 of 5 fail 5 of 5 pass
pop_reref 611 x 326 616 x 376 613 x 326 0.5 +0.3% 3 of 5 fail 5 of 5 pass
pop_autorej 731 x 352 610 x 444 733 x 352 0.5 +0.3% 3 of 5 fail 5 of 5 pass
pop_eegthresh 896 x 300 600 x 350 906 x 300 0.5 +1.1% 3 of 5 fail 5 of 5 pass
pop_rejspec 750 x 326 620 x 392 755 x 326 0.5 +0.7% 3 of 5 fail 5 of 5 pass
pop_plottopo 545 x 221 524 x 329 546 x 221 0.6 +0.2% 3 of 5 fail 5 of 5 pass
pop_firws 1442 x 352 1395 x 524 1451 x 352 0.6 +0.6% 3 of 5 fail 5 of 5 pass
pop_dipfit_gridsearch 570 x 221 520 x 286 578 x 221 0.5 +1.4% 3 of 5 fail 5 of 5 pass
pop_iclabel 371 x 147 407 x 219 371 x 147 0.4 +0.0% 1 of 5 fail 5 of 5 pass

Window sizes are in pixels, drawn on jamming on November 29, 2026 from EEGLAB 579a27d0, EEGPrep develop e435f436 (before) and this branch at 63848ac1 (after). Both checkouts were compared with the develop branch before the captures. The EEGPrep checkout on jamming was 54 commits behind when the work started.

What remains different, and what is not in this pull request

The windows are up to 1.4% wider than MATLAB's, because Qt measures text slightly wider than MATLAB does. Text sits 2 pixels lower inside each control, the same for labels, edit boxes and checkboxes, so their alignment is kept. The shape of buttons, check marks and popup arrows belongs to Qt and is not changed.

Only these ten dialogs use the new layout (layout="supergui" in their specification). The other dialogs keep the earlier layout until they are moved one by one, each with its captures. The only change they see is the centered text of edit boxes. A window taller than the screen does not scroll in the new layout, as in MATLAB. The Mac and Windows height factors of supergui.m are ported and not yet compared on those systems.

Cause and change

supergui.m gives every control a rectangle computed from the geometry alone, then scales the figure by the largest text extent, and inputgui.m appends an empty row and a row of four cells for the buttons. EEGPrep stacked Qt layouts that size each row by its content, with a margin above the buttons, so each dialog needed its own size, margins and spacing.

  • guifunc/supergui.py: getcoord, the conversion of geomhoriz and geomvert, the figure width and height factors, the text shift, and adjustbuttons of inputgui.m, as pure functions with MATLAB's parameter names and defaults (borders, spacing, minwidth, skipline, addbuttons).
  • guifunc/qt.py: for layout="supergui", measures the text of each control as MATLAB's Extent does and places each widget at its rectangle. Controls keep their share of the window when it is resized, as MATLAB's normalized units do.
  • guifunc/spec.py: layout, borders, spacing, minwidth, skipline, addbuttons on DialogSpec; visible and fit_width on ControlSpec; edit text centered by default.
  • Ten specifications lose their hand-set size, margins and spacing. pop_dipfit_gridsearch takes EEGLAB's column widths [1 0.6], and the hidden field of pop_firws is hidden as in EEGLAB instead of showing an extra row.
  • Edit boxes that EEGLAB left-aligns explicitly (file names in pop_importdata, pop_editset, pop_importevent, pop_importepoch, pop_editeventfield, the BIDS dialogs) now say so in their specification.
The geometry test suite (tools/gui_geometry) and tests
  • cases/: the geometry and the control list each EEGLAB function passes to inputgui, recorded from EEGLAB itself by matlab/record_geometry.m with a stand-in inputgui, so no window opens and no data is needed to draw.
  • matlab/draw_geometry.m and draw_geometry.py: the two standalone scripts, fed the same case, each writing the image and the pixel position of every control.
  • compare_positions.py, pair_images.py, vision_rules.md, run_linux.sh: the comparison in pixels, the pairs and the rules for the vision model, and the whole run on Linux, which first prints how far each checkout is behind develop.
  • tests/test_gui_geometry.py, 30 tests: given MATLAB's text extents the port returns MATLAB's control positions within 1 pixel (any platform, no MATLAB); the ten EEGPrep dialogs have the recorded geometry; on Linux the drawn dialogs have MATLAB's rows and aligned edit boxes.

On the final commit 48217a52 the test jobs pass on Ubuntu (Python 3.12 and 3.13), macOS and Windows, with the documentation build, the EEGLAB Python backend job, Ruff, ty and pre-commit. The 30 geometry tests pass on jamming on the final commit 48217a52, whose twenty Python images are identical, byte for byte, to those of 63848ac1 shown above.

The automatic review found that every control was briefly shown as a window of its own before it joined the dialog (setVisible(True) on a widget with no parent). Commit 5d660fd6 hides only the hidden controls. The first Windows run failed because Qt reports a font size of 0 on the Windows runner, which has no fonts, so the text measure gave a window of height 0. Commit 48217a52 reads the size the stylesheet sets.

Report, one page per dialog, EEGLAB beside EEGPrep, before and after: PDF · editable Word

Fixes #875

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @arnodelorme's task in 1m 16s —— View job


Code review

  • Overall assessment: Needs one small change. The port of supergui.m/inputgui.m in guifunc/supergui.py is clean: pure functions with MATLAB's parameter names, and the ten migrated specs are checked against recorded EEGLAB geometry and MATLAB pixel rectangles. One change in the shared widget builder affects every dialog.
  • Highest-risk area: QtDialogRenderer._build_widget (qt.py), which both the new and the old layout use.
  • Merge recommendation: Needs changes.

Blocking

None.

Important

  • Every control briefly opens as its own window, in all dialogs (qt.py#L465).
    • _build_widget creates each widget without a parent, then calls widget.setVisible(control.visible).
    • When visible=True, that call is show() on a parentless widget, so Qt creates a top-level native window for each label, edit box and button. The window disappears only when addWidget reparents the widget.
    • This applies to the layout="qt" dialogs too, not just the ten migrated ones. The offscreen tests can't see it, but on a real desktop windows can flash and each control gets an extra native window.
    • Fix: if not control.visible: widget.hide(). A committable suggestion is in the inline comment.

Nits

None.

Test gaps

None. tests/test_gui_geometry.py covers the layout arithmetic with MATLAB's own extents and checks the specs against the recorded EEGLAB geometry. The pixel test runs on Linux only, which matches where the reference was measured.

EEGLAB parity notes

  • I couldn't compare line by line with supergui.m and inputgui.m: the vendored EEGLAB tree (src/eegprep/eeglab/) is not checked out in this CI runner. The test that feeds MATLAB's recorded Extent values and expects MATLAB's rectangles within 1 px is strong evidence the arithmetic matches.
  • The parity decisions follow EEGLAB:
    • Edit boxes now default to HorizontalAlignment='center', and dialogs that EEGLAB left-aligns set it explicitly.
    • The pop_firws dev field is hidden instead of disabled.
    • pop_dipfit_gridsearch uses [1 0.6].
  • This PR changes only the GUI and no numerical output, so no MATLAB numerical-parity run is needed.

Checked for correctness bugs, EEGLAB parity, data structure compatibility, changed-behavior tests, and CLAUDE.md/AGENTS.md compliance.

Comment thread src/eegprep/functions/guifunc/qt.py Outdated
self._apply_font_hints(widget, control)
self._apply_widget_size_policy(QtWidgets, widget, style)
widget.setEnabled(control.enabled)
widget.setVisible(control.visible)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: every control in every dialog briefly becomes its own top-level window.

_build_widget creates its widgets without a parent (QtWidgets.QLabel(control.string), QtWidgets.QLineEdit(...), and so on). On a parentless widget, setVisible(True) is the same as show(): Qt creates a native top-level window for it right away. The window goes away only when layout.addWidget reparents the widget. This runs for all dialogs, including those still on layout="qt", because both paths go through _build_widget. On a real desktop (xcb, Windows, macOS) this can make windows flash and creates one native window per control. The offscreen tests do not catch it.

Only hiding needs to be explicit. An explicitly hidden child stays hidden when it is reparented and when its parent is shown, so pop_firws's dev field still works:

Suggested change
widget.setVisible(control.visible)
if not control.visible:
widget.hide()

self._apply_font_hints(widget, control)
self._apply_widget_size_policy(QtWidgets, widget, style)
widget.setEnabled(control.enabled)
widget.setVisible(control.visible)
return widget

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 The finding is right and is fixed in 5d660fd6: _build_widget now calls hide() only for a control with visible=False, so no widget is shown before it joins its dialog. On jamming the twenty drawings of the final commit are identical, byte for byte, to those shown in the description.

@arnodelorme
arnodelorme merged commit cea86f8 into develop Nov 29, 2026
12 checks passed
This was referenced Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dialog geometry test suite on Linux: ten dialogs drawn from the same geometry in EEGLAB and EEGPrep, supergui reworked to match MATLAB

1 participant