spacr.qt.widgets.folding_summary¶
Render plain-text run summaries as foldable sections.
The verdict opens by default and later sections begin collapsed. Sections are
parsed from underline-style headings in the text because the input may be a
saved summary from another spaCR version or an unstructured statsmodels
summary, not a live RunSummary object. Text without recognized headings is
shown unchanged.
The source summary remains ordinary plain text suitable for terminals and run artifacts; this widget adds navigation without becoming a second serializer.
Classes¶
A drop-in for the Summary tab's |
Functions¶
|
A section body as |
|
Split |
Module Contents¶
- class spacr.qt.widgets.folding_summary.FoldingSummaryView(parent=None)[source]¶
Bases:
PySide6.QtWidgets.QScrollAreaA drop-in for the Summary tab’s
QPlainTextEdit.Keeps
setPlainTextandtoPlainTextso the panel that fills it does not have to know which it got, and so the text a test reads is the text the file holds.- Parameters:
parent – parent widget.
Build the scrolling summary view with its copy and save actions.
The action row is held as one widget rather than as a bare layout, and that is load-bearing: the rebuild empties the body by taking items out and deleting them, and it only finds widgets. A bare layout was taken out and dropped while the buttons inside it stayed children of the body with nothing laying them out – still visible, still clickable, stuck at their last geometry and painted under everything added afterwards, which is the giant save button reachable only where no text covered it.
- Parameters:
parent – parent widget, or
None.
- font()[source]¶
The fixed-width font the bodies are laid out in.
The summary is aligned with spaces, so the font is part of whether it is readable at all – and a test asserts the widget was GIVEN a fixed font rather than trusting a style hint.
- is_section_expanded(title: str) bool[source]¶
Whether one section is currently open.
- Parameters:
title – the section’s title.
- Returns:
True when expanded.
- save_to_file(path: str = '') str[source]¶
Write the summary out. Returns the path written, or
"".A COPY, NOT A RE-RENDER. The run wrote this text when it was fitted; rendering it again here would differ in the statsmodels
Time:header alone and invite the reader to wonder which is authoritative.
- setPlainText(text: str) None[source]¶
Replace the text and rebuild the folded sections from it.
- Parameters:
text – the summary text.
- setReadOnly(read_only: bool) None[source]¶
Accepted and ignored – see
isReadOnly().Kept so this stays a drop-in for the QPlainTextEdit it replaced: a caller that sets what is already true should not have to know which widget it got.
- Parameters:
read_only – ignored; the view is always read-only.
- spacr.qt.widgets.folding_summary.split_rows(body: str) list[source]¶
A section body as
[(label, value)], or[]if it is not rows.format_run_summaryuses a fixed-width label column for terminal and file output. This parser recovers those rows so the Qt view can reflow the value column to the available width. The label width is inferred from the first labelled row for compatibility with summaries from other versions.- Parameters:
body – one section’s body text, as written by
format_run_summary; None counts as empty.
- spacr.qt.widgets.folding_summary.split_sections(text: str) Tuple[str, List[Tuple[str, str]]][source]¶
Split
textinto the preamble and its(heading, body)sections.- Parameters:
text – the whole summary text; a heading is a line underlined by
-or=of the same length. None counts as empty.- Returns:
everything before the first section, then the sections. A text with no headings comes back as
(text, [])– which is the signal to show it unchanged.