Class: QgsColorSchemeList

class qgis.gui.QgsColorSchemeList

Bases: PyQt5.QtWidgets.QTreeView

An editable list of color swatches, taken from an associated QgsColorScheme.

New in version 2.5.

QgsColorSchemeList(parent: QWidget = None, scheme: QgsColorScheme = None, context: str = ‘’, baseColor: Union[QColor, Qt.GlobalColor, QGradient] = QColor()) Construct a new color swatch grid.

Parameters:
actionEvent(self, QActionEvent)
addColor(self, color: QColor | Qt.GlobalColor | QGradient, label: str = '', allowDuplicate: bool = False)

Adds a color to the list

Parameters:
  • color (Union[QColor) – color to add

  • label (str = '') – optional label for color

  • allowDuplicate (bool = False) – set to True to allow duplicate colors to be added, ie colors which already exist in the list

changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEditor(self, QWidget, QAbstractItemDelegate.EndEditHint)
closeEvent(self, QCloseEvent)
colorSelected

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

QgsColorSchemeList.columnCountChanged(self, int, int)
columnMoved(self)
QgsColorSchemeList.columnResized(self, int, int, int)
commitData(self, QWidget)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
copyColors(self)

Copies colors from the list to the clipboard

See also

pasteColors()

create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
QgsColorSchemeList.currentChanged(self, QModelIndex, QModelIndex)
customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
dirtyRegionOffset(self) QPoint
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
drawBranches(self, QPainter, QRect, QModelIndex)
drawFrame(self, QPainter)
drawRow(self, QPainter, QStyleOptionViewItem, QModelIndex)
drawTree(self, QPainter, QRegion)
dropEvent(self, QDropEvent)
dropIndicatorPosition(self) QAbstractItemView.DropIndicatorPosition
edit(self, QModelIndex)
edit(self, QModelIndex, QAbstractItemView.EditTrigger, QEvent) bool
editorDestroyed(self, QObject)
enterEvent(self, QEvent)
event(self, QEvent) bool
eventFilter(self, QObject, QEvent) bool
executeDelayedItemsLayout(self)
exportColorsToGpl(self, file: QFile) bool

Export colors to a GPL palette file from the list

Parameters:

file (QFile) – destination file

Return type:

bool

focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
hideEvent(self, QHideEvent)
horizontalOffset(self) int
horizontalScrollbarAction(self, int)
horizontalScrollbarValueChanged(self, int)
importColorsFromGpl(self, file: QFile) bool

Import colors from a GPL palette file to the list

Parameters:

file (QFile) – file to import

Return type:

bool

indexRowSizeHint(self, QModelIndex) int
initPainter(self, QPainter)
initStyleOption(self, QStyleOptionFrame)
inputMethodEvent(self, QInputMethodEvent)
isDirty(self) bool

Returns whether the color scheme list has been modified

Return type:

bool

Returns:

True if colors have been modified

isIndexHidden(self, QModelIndex) bool
isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, event: QKeyEvent)
Parameters:

event (QKeyEvent) –

keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, event: QMouseEvent)
Parameters:

event (QMouseEvent) –

mouseReleaseEvent(self, event: QMouseEvent)
Parameters:

event (QMouseEvent) –

moveCursor(self, QAbstractItemView.CursorAction, Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]) QModelIndex
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
paintEvent(self, QPaintEvent)
pasteColors(self)

Pastes colors from clipboard to the list

See also

copyColors()

receivers(self, PYQT_SIGNAL) int
reexpand(self)
removeSelection(self)

Removes any selected colors from the list

resizeEvent(self, QResizeEvent)
rowHeight(self, QModelIndex) int
QgsColorSchemeList.rowsAboutToBeRemoved(self, QModelIndex, int, int)
QgsColorSchemeList.rowsInserted(self, QModelIndex, int, int)
QgsColorSchemeList.rowsRemoved(self, QModelIndex, int, int)
saveColorsToScheme(self) bool

Saves the current colors shown in the list back to a color scheme, if supported by the color scheme.

Note

this method is only effective if the color scheme is editable

Return type:

bool

scheduleDelayedItemsLayout(self)
scheme(self) QgsColorScheme

Returns the scheme currently selected in the list.

See also

setScheme()

New in version 3.0.

Return type:

QgsColorScheme

QgsColorSchemeList.scrollContentsBy(self, int, int)
QgsColorSchemeList.scrollDirtyRegion(self, int, int)
selectedIndexes(self) List[QModelIndex]
QgsColorSchemeList.selectionChanged(self, QItemSelection, QItemSelection)
selectionCommand(self, QModelIndex, event: QEvent = None) QItemSelectionModel.SelectionFlags
sender(self) QObject
senderSignalIndex(self) int
setDirtyRegion(self, QRegion)
setScheme(self, scheme: QgsColorScheme, context: str = '', baseColor: QColor | Qt.GlobalColor | QGradient = QColor())

Sets the color scheme to show in the list

Parameters:
  • scheme (QgsColorScheme) – QgsColorScheme for colors to show in the list

  • context (str = '') – context string provided to color scheme

  • baseColor (Union[QColor) – base color for color scheme

See also

scheme()

setSelection(self, QRect, Union[QItemSelectionModel.SelectionFlags, QItemSelectionModel.SelectionFlag])
setState(self, QAbstractItemView.State)
QgsColorSchemeList.setViewportMargins(self, int, int, int, int)
setViewportMargins(self, QMargins) None
sharedPainter(self) QPainter
showEvent(self, QShowEvent)
showExportColorsDialog(self)

Displays a file picker dialog allowing users to export colors from the list into a file.

New in version 3.0.

showImportColorsDialog(self)

Displays a file picker dialog allowing users to import colors into the list from a file.

New in version 3.0.

sizeHintForColumn(self, int) int
startDrag(self, Union[Qt.DropActions, Qt.DropAction])
state(self) QAbstractItemView.State
tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
updateEditorData(self)
updateEditorGeometries(self)
updateGeometries(self)
updateMicroFocus(self)
verticalOffset(self) int
verticalScrollbarAction(self, int)
verticalScrollbarValueChanged(self, int)
viewOptions(self) QStyleOptionViewItem
viewportEvent(self, QEvent) bool
viewportMargins(self) QMargins
viewportSizeHint(self) QSize
visualRegionForSelection(self, QItemSelection) QRegion
wheelEvent(self, QWheelEvent)