spacr.qt.button_roles

Semantic styling and busy-state handling for action buttons.

Qt stylesheets cannot select a button by its visible text. spaCR also creates many buttons dynamically through QDialogButtonBox, so this application event filter tags buttons when they appear rather than relying on every screen to repeat styling code.

Functions

action_role(→ Optional[str])

Classify a visible label as positive, negative, or neutral.

alive(→ bool)

Is this button's C++ side still there?

install_button_roles(→ None)

Install semantic action-button behavior on a running application.

set_button_busy(→ None)

Show or clear the persistent solid operation state.

Module Contents

spacr.qt.button_roles.action_role(text: str) → str | None[source]

Classify a visible label as positive, negative, or neutral.

Parameters:

text – the button’s visible label. Mnemonic & and ellipses are stripped and case is folded; the label is positive or negative when it is, or starts with, a word in POSITIVE_PREFIXES or NEGATIVE_PREFIXES, otherwise None.

spacr.qt.button_roles.alive(button) → bool[source]

Is this button’s C++ side still there?

A lambda target=button: ... connected to a signal keeps the PYTHON wrapper alive while Qt deletes the C++ object under it – the wrapper has no way to tell Qt to drop the connection, because the connection is not a bound method of a QObject. Touching the wrapper afterwards raises

RuntimeError: libshiboken: Internal C++ object (PySide6.QtWidgets.QPushButton) already deleted.

which is what spaCR printed on every launch, once per wired button, for a button the user never pressed. shiboken answers the question directly; the exception is the fallback for a build where it cannot be imported.

Parameters:

button – the Qt widget wrapper to check, or None (not alive).

spacr.qt.button_roles.install_button_roles(app=None) → None[source]

Install semantic action-button behavior on a running application.

spacr.qt.button_roles.set_button_busy(button: PySide6.QtWidgets.QPushButton, busy: bool) → None[source]

Show or clear the persistent solid operation state.

A no-op for a button whose C++ side has been deleted – see alive(). Returning quietly is right here: the state being set is a VISUAL one on a widget that is gone, so there is nothing to show and nothing was lost.

Parameters:
  • button – the button whose buttonActionBusy property is set.

  • busy – truthy to show the busy state, falsy to clear it; the button is repolished only when the value changes.