spacr.qt.widgets.model_card_viewer

Viewer for the 3-page model cards of the Model Zoo.

Shows the page image of a card scaled to fit, with Previous and Next, a “1 / 3” counter, Left and Right keys and a link to the model on Hugging Face. The images are fetched on first view in a worker thread and cached; without them the viewer shows the same three pages as text from the card data that ships with spaCR. Clicking the image opens it larger in a dialog.

Classes

ModelCardViewer

Page through the card of one model.

Module Contents

class spacr.qt.widgets.model_card_viewer.ModelCardViewer(parent=None, *, threaded: bool = True, fetch: Callable[[str], bytes] | None = None, enlargeable: bool = True)[source]

Bases: PySide6.QtWidgets.QFrame

Page through the card of one model.

Parameters:
  • parent – parent widget.

  • threaded – fetch the images on a worker thread; False fetches inline, for tests.

  • fetch – byte source taking a URL, handed to spacr.model_cards.fetch_pages(); None uses the network.

  • enlargeable – clicking the image opens a larger dialog.

card() → Dict[str, Any] | None[source]

The card data being shown, or None.

counter_text() → str[source]

The “1 / 3” text.

go_to(page: int) → None[source]

Show page page (zero-based), clamped to the pages.

Parameters:

page – the page index, from 0.

keyPressEvent(event)[source]

Left and Right turn the page.

Parameters:

event – the Qt key event.

next_page() → None[source]

Show the next page; stays on the last.

page() → int[source]

The zero-based current page.

previous_page() → None[source]

Show the previous page; stays on the first.

set_card(card: Dict[str, Any] | None) → None[source]

Show card from page 1, fetching its images when not cached.

Parameters:

card – the card data, or None to show nothing.

showing_image() → bool[source]

True when the current page is the picture, not the text.

status_text() → str[source]

The line under the page.