spacr.qt.widgets.channel_picker

Compact RGB channel controls for image-view settings.

The widget presents R, G, and B as independent toggles while preserving the canonical comma-separated value used by existing settings files. This keeps the active channels visible without accepting ambiguous free-form spellings.

Classes

ChannelPicker

Select RGB channels with three checkboxes.

Functions

parse(→ tuple)

Return the recognized channels in canonical RGB order.

to_text(→ str)

Serialize channel names as a canonical comma-separated string.

Module Contents

class spacr.qt.widgets.channel_picker.ChannelPicker(value: Any = '', parent: PySide6.QtWidgets.QWidget | None = None, *, allow_none: bool = True)[source]

Bases: PySide6.QtWidgets.QWidget

Select RGB channels with three checkboxes.

The public value is a canonical comma-separated string such as "r,g,b". Clearing every channel can be allowed for normalization controls or refused for displays that must retain a visible channel.

Initialize the picker.

Parameters:
  • value (Any, default='') – Initial channel selection.

  • parent (QWidget, optional) – Parent widget.

  • allow_none (bool, default=True) – Allow every channel to be cleared. Image displays normally set this to False; normalization controls may use an empty value to mean that no channel is normalized.

setText(value: Any) → None[source]

Set the picker from a settings string.

NAMED FOR QLineEdit’s method on purpose: the settings form writes every field the same way, so a control that took a different setter would have to be special-cased everywhere it is poured into.

Parameters:

value – the channels, as the settings dict spells them.

set_value(value: Any) → None[source]

Apply a selection and emit one consolidated change signal.

Parameters:

value – the channels to check: a comma-separated string, an iterable of names, or an empty value, read by parse(); unknown names are ignored.

value() → str[source]

Return the selected channels in canonical stored form.

spacr.qt.widgets.channel_picker.parse(value: Any) → tuple[source]

Return the recognized channels in canonical RGB order.

Parameters:

value (Any) – A comma-separated string, an iterable of names, or an empty value.

Returns:

tuple of str – Recognized channel names in ('r', 'g', 'b') order. Unknown names are omitted rather than inferred.

spacr.qt.widgets.channel_picker.to_text(names: Iterable[str]) → str[source]

Serialize channel names as a canonical comma-separated string.

Parameters:

names – channel names, stripped and lower-cased; names outside ('r', 'g', 'b') are dropped.