spacr.qt.regex_editor

Regex editor popup — appears when a dropped folder can’t be parsed by any built-in regex, or when the user clicks “Edit regex” from the mask app.

Features:

  • Editable regex line + “Try” button.

  • Live tabular preview of the first 10 filenames parsed by the current regex.

  • “Auto detect” button (heuristic — see spacr.qt.regex_detect.auto_detect_regex()).

  • Dropdown to pick a built-in as a starting point.

  • “Save” writes the regex into the target AppScreen’s custom_regex setting; “Cancel” closes without changes.

The dialog is pure UI — all logic lives in spacr.qt.regex_detect.

Classes

RegexEditorDialog

Modal editor for the filename metadata regex.

Module Contents

class spacr.qt.regex_editor.RegexEditorDialog(sample_filenames: List[str], initial_regex: str = '', multichannel: bool = True, parent=None)[source]

Bases: PySide6.QtWidgets.QDialog

Modal editor for the filename metadata regex.

Parameters:
  • sample_filenames – bare filenames from the dropped folder used for the live preview (first 20 or so).

  • initial_regex – pre-fill the input with this pattern; empty means we run auto-detect on show.

  • multichannel – True for regular multi-channel plates; False for single-channel data (relaxes the warning set).

  • parent – optional parent widget.

Variables:

regex – the final chosen regex; only meaningful after exec() returned QDialog.Accepted.

Build the filename-regex editor over a sample of filenames.

Parameters:
  • sample_filenames – names to match against; the first twenty are kept, which is enough to see whether a pattern generalises.

  • initial_regex – the pattern to open with; empty runs auto-detect.

  • multichannel – validate that a channel group is captured.

  • parent – parent widget, or None.

resizeEvent(event)[source]

Re-fit the wrapped labels to the width they have just been given.

Both labels grow when the dialog narrows, and a label that is only allowed its one-line hint is the clipping this dialog was found with: the intro wrapped to 54 px inside 36, and the sentence naming chanID – the one thing the dialog exists to explain – was the part cut off.

Parameters:

event – the resize event, passed to the base class first; the labels are then re-fitted to the dialog’s new width.