Skip to content

CmapCatalogComboBox

A QComboBox with every colormap in the cmap catalog. Typing in it shows the colormaps whose names contain the text, and currentColormap() returns a cmap.Colormap.

Requires cmap

Colormaps come from the cmap library, which you can install with the cmap extra:

pip install "superqt[cmap]"

The categories and interpolation keyword arguments limit the colormaps to those in some categories (such as "sequential"), or with one interpolation (such as "linear"). By default, colormaps are listed by their short names, and by their full names (namespace:name) only where two namespaces use the same short name; pass prefer_short_names=False to always use full names.

CmapCatalogComboBox CmapCatalogComboBox
from qtpy.QtWidgets import QApplication

from superqt.cmap import CmapCatalogComboBox

app = QApplication([])

catalog_combo = CmapCatalogComboBox(interpolation="linear")
catalog_combo.setCurrentText("viridis")
catalog_combo.show()

app.exec()

CmapCatalogComboBox

CmapCatalogComboBox(
    parent: QWidget | None = None,
    *,
    categories: Container[Category] = (),
    prefer_short_names: bool = True,
    interpolation: Interpolation | None = None,
)

A combo box for selecting a colormap from the entire cmap catalog.

Parameters:

  • parent (QWidget, default: None ) –

    The parent widget.

  • prefer_short_names (bool, default: True ) –

    If True (default), short names (without the namespace prefix) will be preferred over fully qualified names. In cases where the same short name is used in multiple namespaces, they will all be referred to by their fully qualified (namespaced) name.

  • categories (Container[Category], default: () ) –

    If provided, only return names from the given categories.

  • interpolation (Interpolation, default: None ) –

    If provided, only return names that have the given interpolation method.

Subclass of QComboBox

CmapCatalogComboBox inherits all of QComboBox's methods, signals, and properties. Only those that superqt adds or changes are listed here.

Signals

  • currentColormapChanged(Colormap)

Methods

A combo box for selecting a colormap from the entire cmap catalog.

Parameters:

  • parent (QWidget, default: None ) –

    The parent widget.

  • prefer_short_names (bool, default: True ) –

    If True (default), short names (without the namespace prefix) will be preferred over fully qualified names. In cases where the same short name is used in multiple namespaces, they will all be referred to by their fully qualified (namespaced) name.

  • categories (Container[Category], default: () ) –

    If provided, only return names from the given categories.

  • interpolation (Interpolation, default: None ) –

    If provided, only return names that have the given interpolation method.

currentColormap

currentColormap() -> Colormap | None

Returns the currently selected Colormap or None if not yet selected.