pyqt_reactive.forms.widget_operations

Centralized widget operations using ABC-based dispatch.

Replaces scattered duck typing with explicit ABC checks. Eliminates WIDGET_UPDATE_DISPATCH and WIDGET_GET_DISPATCH tables.

Design: - Single source of truth for widget operations - ABC-based dispatch (no hasattr checks) - Fail-loud on missing implementations - Discoverable via registry

Classes

WidgetOperations()

Centralized widget operations using ABC-based dispatch.

class pyqt_reactive.forms.widget_operations.WidgetOperations[source]

Centralized widget operations using ABC-based dispatch.

Replaces scattered duck typing with explicit ABC checks. Eliminates WIDGET_UPDATE_DISPATCH and WIDGET_GET_DISPATCH.

Example

ops = WidgetOperations()

# Get value (fails loud if widget doesn’t implement ValueGettable) value = ops.get_value(widget)

# Set value (fails loud if widget doesn’t implement ValueSettable) ops.set_value(widget, 42)

# Set placeholder (fails loud if widget doesn’t implement PlaceholderCapable) ops.set_placeholder(widget, “Pipeline default: 100”)

static get_value(widget: Any) Any[source]

Get value from any widget implementing ValueGettable.

Parameters:

widget – The widget to get value from

Returns:

The widget’s current value

Raises:

TypeError – If widget doesn’t implement ValueGettable ABC

static set_value(widget: Any, value: Any) None[source]

Set value on any widget implementing ValueSettable.

Parameters:
  • widget – The widget to set value on

  • value – The value to set

Raises:

TypeError – If widget doesn’t implement ValueSettable ABC

static set_placeholder(widget: Any, text: str) None[source]

Set placeholder on any widget implementing PlaceholderCapable.

Parameters:
  • widget – The widget to set placeholder on

  • text – The placeholder text

Raises:

TypeError – If widget doesn’t implement PlaceholderCapable ABC

static configure_range(widget: Any, minimum: float, maximum: float) None[source]

Configure range on any widget implementing RangeConfigurable.

Parameters:
  • widget – The widget to configure

  • minimum – Minimum value

  • maximum – Maximum value

Raises:

TypeError – If widget doesn’t implement RangeConfigurable ABC

static connect_change_signal(widget: Any, callback: Callable[[Any], None]) None[source]

Connect change signal on any widget implementing ChangeSignalEmitter.

Parameters:
  • widget – The widget to connect signal on

  • callback – Callback function receiving new value

Raises:

TypeError – If widget doesn’t implement ChangeSignalEmitter ABC

static disconnect_change_signal(widget: Any, callback: Callable[[Any], None]) None[source]

Disconnect change signal on any widget implementing ChangeSignalEmitter.

Parameters:
  • widget – The widget to disconnect signal from

  • callback – Callback function to disconnect

Raises:

TypeError – If widget doesn’t implement ChangeSignalEmitter ABC

static get_all_value_widgets(container: Any) list[source]

Get all widgets that implement ValueGettable ABC.

Replaces findChildren() with explicit type lists. Uses ABC checking instead of duck typing.

Parameters:

container – The container widget to search in

Returns:

List of widgets implementing ValueGettable

Example

>>> ops = WidgetOperations()
>>> form = MyFormWidget()
>>> value_widgets = ops.get_all_value_widgets(form)
>>> values = {w.objectName(): ops.get_value(w) for w in value_widgets}
static try_set_placeholder(widget: Any, text: str) bool[source]

Try to set placeholder, return False if widget doesn’t support it.

This is the ONLY acceptable use of “try” pattern - when placeholder support is truly optional and we want to gracefully skip widgets that don’t support it.

Parameters:
  • widget – The widget to set placeholder on

  • text – The placeholder text

Returns:

True if placeholder was set, False if widget doesn’t support it

static try_configure_range(widget: Any, minimum: float, maximum: float) bool[source]

Try to configure range, return False if widget doesn’t support it.

Similar to try_set_placeholder - acceptable for optional configuration.

Parameters:
  • widget – The widget to configure

  • minimum – Minimum value

  • maximum – Maximum value

Returns:

True if range was configured, False if widget doesn’t support it