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

FoldingSummaryView

A drop-in for the Summary tab's QPlainTextEdit.

Functions

split_rows(→ list)

A section body as [(label, value)], or [] if it is not rows.

split_sections(→ Tuple[str, List[Tuple[str, str]]])

Split text into the preamble and its (heading, body) sections.

Module Contents

class spacr.qt.widgets.folding_summary.FoldingSummaryView(parent=None)[source]

Bases: PySide6.QtWidgets.QScrollArea

A drop-in for the Summary tab’s QPlainTextEdit.

Keeps setPlainText and toPlainText so 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.

copy_to_clipboard() → bool[source]

The whole summary, as the run wrote it. Returns whether it went.

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.

isReadOnly() → bool[source]

Always. A summary is a run artefact, not a document to edit.

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.

section_titles() → tuple[source]

Every section’s title, in document order.

Returns:

the titles.

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.

set_section_expanded(title: str, expanded: bool) → None[source]

Open or close one section.

Parameters:
  • title – the section’s title.

  • expanded – True to open it.

toPlainText() → str[source]

The text as set, whatever is folded away right now.

THE SOURCE, NOT THE VIEW. Folding is a display state, so a caller copying this out gets the whole summary rather than only the parts that happen to be open.

Returns:

the summary text.

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_summary uses 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 text into 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.

Nested helpers

FoldingSummaryView._table._tint(label: str, value: str) → str

One cell, coloured only when the row is an alarm.

spacr/qt/widgets/folding_summary.py:389